Posts by Wallace Maxters • 102,340 points
1,984 posts
-
1
votes3
answers4384
viewsA: Difficulties in Sending Email using PHP
I use frameworks. They often have their own mechanisms that do not use the PHP mail function. The problem with php’s mail function is that you have to tinker with a configuration file. I always have…
-
1
votes1
answer172
viewsQ: Imgselect: Mediastream stop is not a Function
I asked this question here at Stackoverflow in English: getUserMedia has now been discontinued on https connections? And I noticed that after having uploaded a system to the server, the camera…
javascriptasked Wallace Maxters 102,340 -
18
votes3
answers4752
viewsA: What is the difference between 'Yield' and 'Return' in PHP?
According to the php manual. Simply put: One is about a return of a value, another is for creating a Generator. YIELD A Yield statement looks a lot like a return, except that instead of stopping the…
-
17
votes1
answer990
viewsQ: Is using an empty catch a bad practice?
There have been cases where I needed to make use of methods that launched exception if any error occurred, but the exception would stop the execution of script, what would be something unwanted. For…
-
6
votes1
answer1768
viewsQ: What is a loopback interface?
I was going through socket connection issues on my server: Causing the error [could not bind to "tcp://127.0.0.1:8843". Cannot assign request Adress]? I managed to solve the problem. The technician…
-
1
votes1
answer263
viewsA: What causes the error [could not bind to "tcp://127.0.0.1:8843". Cannot assign request Adress]?
Problem solved. Hosting employee said the problem was that the loopback interface was not running. The interesting thing is that, as disassembled in the question, the section that uses the function…
phpanswered Wallace Maxters 102,340 -
1
votes1
answer263
viewsQ: What causes the error [could not bind to "tcp://127.0.0.1:8843". Cannot assign request Adress]?
Come on. I have a PHP script that serves to create a websocket server for my application. I am using HTML5 websocket. To create the server, I am using the Ratchet library found on the site…
phpasked Wallace Maxters 102,340 -
14
votes5
answers42959
viewsQ: Function equivalent to Trim (function to remove extra spaces at the beginning and end) in Python?
In PHP and Javascript, we have the function trim that serves to trim a string, removing extra spaces at the beginning and end. Thus: $str = ' meu nome é wallace '; var_dump(trim($str)); //…
-
49
votes6
answers6389
viewsQ: What is a legacy code?
I’ve heard that term from some people, but I’m not usually good with those technical terms. What would be a legacy code? It is related to the code being exceeded?
-
6
votes1
answer187
viewsQ: What are the PEP’s in Python?
I was researching about the Type Hints in Python and came across this page. PEP 0484 - Type Hints What would this PEP be? This is some kind of proposal for the next versions of languages?…
pythonasked Wallace Maxters 102,340 -
13
votes2
answers995
viewsQ: PHP 7 has argument typing and return, but is it optional. Is that good or bad?
I would not like to raise here a controversial issue regarding the PHP 7 language, which was released recently, but only understand a few points regarding typing. Come on: In versions prior to PHP…
-
5
votes1
answer58870
viewsQ: How to know if a port is open or not on Linux
I have a PHP script that acts as a chat server (websocket) that I have on a given system. I realize that sometimes unexpectedly this service stops running. It runs through the command nohup. I am…
-
13
votes3
answers505
viewsA: What are the native exceptions of PHP?
Regarding PHP 7, the exceptions in common PHP errors were implemented, such as Warning, Fatal Error and Parse Error. Here is the list of errors that can be captured in PHP 7: Error It’s some kind of…
-
2
votes2
answers355
viewsA: Tokenmismatchexception after any ajax error on Laravel 5.1
I believe that you can solve this in the following way: Display the token in an attribute of a DOM element Capture this DOM token value in each ajax request and send it as the value _token. So it…
-
4
votes2
answers7168
viewsQ: How to discover the version of my C/C++ on the Linux operating system?
I’d like to learn how to find the version of mine C/C++ in the operating system Linux. How could I do that through Terminal?
-
6
votes1
answer356
viewsQ: What is * for in the expression "Foo* foo = new Foo" in C++?
I was looking into this question done in SOEN. There is teaching to instantiate a certain class. I was able to understand more or less how it works, because when I use my example, it is giving error…
-
3
votes2
answers1595
viewsA: How to make Jqueryui autocomplete with PHP return multiple data?
Simple, in jQuery UI, for you to have the value searched in the database displayed in the list generated by the autocomplete, you do not need to always use a string array, but you can use an array…
-
6
votes2
answers5403
viewsQ: How to find out which extensions are installed in my PHP?
Is there any way to find out which extensions are installed in my PHP? I already know I can do it with phpinfo, but I find the visualization confusing. There is a simpler way, ie only the lists of…
phpasked Wallace Maxters 102,340 -
1
votes2
answers245
viewsA: Data Display Issues Laravel 5.1
That bit of code is wrong $escolaridade = cadastro.escolaridade::all(); By chance you come from another language and are trying to access members of classes or objects? Your code indicates that you…
-
1
votes3
answers2082
viewsA: After "apt-get dist-upgrade" command, PHP 7 was installed. How to go back to 5?
I don’t know if it has to do with what @Danielomine said about the package conflict issue, but at first I don’t think the command apt-get install php5 works to install PHP 5 (which seems obvious),…
-
2
votes3
answers2082
viewsQ: After "apt-get dist-upgrade" command, PHP 7 was installed. How to go back to 5?
I use Ubuntu 14.04. And when I went to execute this command apt-get dist-upgrade here on my machine, he installed PHP 7. I’ve already removed PHP 7 like this: apt-get purge php.* But when I do so:…
-
2
votes1
answer34
viewsA: How to Lock Project Version on Symfony
In Composer you will define as follows: "symfony/symfony": "2.6.*", Doing so, when you use the command composer update, only the bug fixes specific to this version will be updated.…
symfony-2answered Wallace Maxters 102,340 -
11
votes2
answers1551
viewsQ: What is the difference between repeat and while on the moon?
Is there any difference as to the usability of repeat and while on the moon? In my opinion, the two appear to have the same purpose. Not taking syntax into account, there is some difference between…
luaasked Wallace Maxters 102,340 -
4
votes3
answers2583
viewsA: include, require inside functions methods
It doesn’t cause problems. At least I know PHP 5.0 up and never had problems with it. include/require within functions can be done normally. The difference is that it will get "stuck" within the…
-
87
votes2
answers4860
viewsQ: Algorithm to detect nudity with good accuracy
I was researching some libraries in Python that could detect nudity in photos, so that somehow I could avoid inappropriate content on my site. Then I found the library nudity. The problem is that,…
-
8
votes1
answer451
viewsQ: In Python 2 is it more performative to use range or xrange?
The programming language I use the most is PHP :( and, after it has been implemented Generators in version 5.5, it is said to be faster to use it for generating numbers in sequence than with the…
pythonasked Wallace Maxters 102,340 -
2
votes1
answer103
viewsA: htaccess restrictions
The problem is that your href is thus (concerning the path current): pagina/teste/ Should be like this: /pagina/teste/…
-
14
votes2
answers1684
viewsA: How does namespaces work in PHP?
Namespaces are mainly useful to avoid name collision. Implemented in PHP 5.3. It is very common to see older PHP libraries using a standard that consists of using underline in class names, to avoid…
-
0
votes4
answers352
viewsA: Error inserting json in Mysql with PHP
Try this: mysql_real_espace_string(json_encode($imagens)); I already warn you that functions mysql_ are discontinued in recent versions of PHP. You must migrate to mysqli_ or PDO. Recommended…
-
0
votes1
answer50
viewsA: Rule in model using str_replace() to replace "," with "."
The field where you enter this value must be configured in Mysql as float, and not as int. It is also important to remember that in this case you are getting one string, and not a value float. Try…
cakephpanswered Wallace Maxters 102,340 -
2
votes6
answers22962
viewsA: How to calculate percentage?
You can also do as follows: $total = 4000 $pctm = 30.00 $valor_com_desconto = $total - ($total * $pctm * 0.01) Divide by 100 and multiply by 0.01 gives the same result.…
-
3
votes1
answer592
viewsQ: What is a random seed?
I asked a question here about a question I had about how we used random number generation. What is Mersenne Twister? There I quote that PHP uses a term called "sow random numbers" or "random seed".…
random-numbersasked Wallace Maxters 102,340 -
4
votes1
answer984
viewsQ: What is Mersenne Twister?
PHP has a function called rand. There is also a function called mt_rand. I was studying about these functions and realized that, in previous versions, it was necessary to use such a "random number…
random-numbersasked Wallace Maxters 102,340 -
2
votes1
answer967
viewsQ: Guzzle and asynchronous requests in PHP
I was taking a look at the documentation of GuzzleHttp and I saw that there is an explanation on how to use it to make asynchronous requests. $promise = $client->requestAsync('GET',…
-
0
votes3
answers445
viewsA: How to make the relationship of an extra field (pivot) in belongsToMany
There is a library called TriplePivot which allows you to relate three tables through a pivot table. https://github.com/jarektkaczyk/Eloquent-triple-pivot…
-
25
votes4
answers4072
viewsQ: Because of user experience, should confirmation buttons be left or right?
I have this doubt. We are setting up a system where there is a modal that asks the user whether he wants to perform such an operation or not. My question arose regarding the position of the…
uxasked Wallace Maxters 102,340 -
0
votes1
answer464
viewsA: Return 2 date type in ajax
If you need "two returns" on ajax then use two indexes. Example: echo json_encode('retorno' => $retorno, 'horario' => $horario)) In Javascript, you can capture these indexes that have been…
-
1
votes1
answer2007
viewsA: Database driver Cake Database Driver Mysql cannot be used due to a Missing PHP Extension
This error message happens because the extension php_pdo_mysql.dll is not installed and/or enabled in its php.ini. After doing this you need to restart the server you are using (apache or the bake…
-
1
votes1
answer2084
viewsA: Set Laravel to Standard Level/Directory
There is a way to settle this by .htaccess and by laravel. And an extra gambit I’ll teach you (maybe it’s the easiest way). HTACCESS That of htaccess consists of writing the following code:…
-
2
votes1
answer332
viewsA: Read files in RTF format and generate a TXT file
It would be easier if you used libraries for this purpose. https://github.com/jstewmc/rtf According to the example that’s there on Github, you can do: $doc = new \Jstewmc\Rtf\Document();…
phpanswered Wallace Maxters 102,340 -
2
votes1
answer2261
viewsA: How to resolve Uninitialized string offset error: 0 in
This is because the string does not have offset 0. That is, it is empty. Example: $a = '' $a{0}; // PHP error: Uninitialized string offset: 0 As stated in some comments, you can use the function…
phpanswered Wallace Maxters 102,340 -
8
votes4
answers4310
viewsA: Enter key do not give Submit
So too does: $('#form').bind('submit', false); $('button#submit').click(function() { $('#form').submit(); }); This will only send the form when you click the Submit button.…
-
3
votes4
answers4957
viewsA: Call static class method by static variable
@Maniero has already demonstrated that your code is wrong. You used self outside the class. What happens in your case is a Parse Error. This is a limitation of current versions of PHP, which has…
-
7
votes1
answer78
viewsA: Is there any way to add css rules by javascript?
The @Gabe gave a reference in which, after being tested, I have proven that it works (at least on Google Chrome 46). It is through the method insertRule, present in CSSStyleSheet. To access it, you…
-
6
votes1
answer78
viewsQ: Is there any way to add css rules by javascript?
If I have the following tag style: <style> body{ color:red; } </style> It would be possible to add another new css rule like inside this style through the Javascript? For example, I want…
-
3
votes1
answer548
viewsA: Access Pseudo Elements ::after and ::before and Other
With jQuery it is not possible to access the pseudo elements. What can be done is to use the functions after and before jQuery, but they will create the data in the DOM, are not only pseudo…
-
1
votes1
answer901
viewsA: Stop settimeOut Javascript
Probably the problem lies in the fact that time be declared within verificaComplet. That makes it, every time it’s called verificaComplet within the setTimeout, a new instance is created. Maybe what…
-
2
votes1
answer1666
viewsA: Looping jquery setInterval
A good way to make this logic of loops where you have a value being incremented, but at some point this value should get to the beginning is using array and a logic with module %. Example:…
-
0
votes1
answer60
viewsA: How to add a new node to an XML with jQuery?
With jQuery you’d have to do so: var $node = $('<nota/>', { ordem : 4, html: [ $('<nome/>', {html: 'Hugo'}), $('<data />', {html: '10/05/2001'}), // E assim por diante ] }) As you…
-
3
votes1
answer87
viewsQ: How to make an Extract within a function without the variables colliding with the parameter variables?
I have a function that loads certain route through the include. The parameters of this function are $file and $data. The file parameter is the name of the file that will be loaded with include…
phpasked Wallace Maxters 102,340