Posts by Wallace Maxters • 102,340 points
1,984 posts
-
3
votes1
answer586
viewsQ: How do I find out which file includes the other in PHP?
I would like to know in PHP how do I find out which is the parent file, in an inclusion, through the child file. Example: avo.php pai.php php son. In the archive avo.php I have: include_once…
-
1
votes3
answers145
viewsA: Is that a bug in stdClass?
To further strengthen our theory regarding the question, I will give my opinion on the subject. As exemplified by our friend, the question is not whether you have a constructor or function with or…
phpanswered Wallace Maxters 102,340 -
3
votes3
answers145
viewsQ: Is that a bug in stdClass?
In PHP it is possible to declare a variable at the same time as we pass it as a function parameter or at class instantiation. Let me give you an example with the function is_file and the class…
phpasked Wallace Maxters 102,340 -
2
votes1
answer270
viewsQ: Is there any way to translate the error messages produced by PHP?
Is there any way to translate error messages in PHP? Example: English Use of Undefined Constant X Português Use of indefinite constant X…
-
0
votes1
answer92
viewsA: Escapeshellarg() error
This is a function used to work with command line. So probably the hosting server you are using is blocking it for security reasons. You will have to ask support to release this function in php.ini…
phpanswered Wallace Maxters 102,340 -
1
votes1
answer781
viewsQ: How to get the default temporary operating system directory in PHP?
In PHP, there is some way [or some function that has the purpose] to get the directory where temporary files are saved in a given operating system? I know the function tempnam generates a temporary…
-
20
votes1
answer432
viewsQ: What is the ~ (til) operator for in PHP?
What is the operator for ~ (til) in PHP? I’ve seen things like: echo ~PHP_INT_MAX Until then I thought it was to "reverse" a number to negative, or something like that, but with the tests I saw that…
-
5
votes1
answer737
viewsQ: How to detect the internet connection via javascript?
Is there any way to "know", via javascript, if the internet connection has been lost? For example, to try a reconnection with websocket, if it detects that the internet connection has been lost and…
javascriptasked Wallace Maxters 102,340 -
0
votes2
answers398
viewsA: Alternatives to pass data through Hidden fields
I believe that the best alternative is to use the framework’s own resource for this id that you want to spend. parameters by URL and findOrFail Controller: public function anyEdit($id) { $usuario =…
-
2
votes1
answer674
viewsA: Transform JSON result to 'uppercase'
I’ll leave my answer in case you do this in PHP. $array = json_decode($meu_json, true); array_walk_recursive($array, function (&$value) { $value = mb_strtoupper($value, 'UTF-8'); });…
-
10
votes3
answers7520
viewsQ: What is void in javascript?
I could contemplate a javascript code that had the following code: if (context === void 0) { // faça algo } I don’t understand what that chunk of code means or what it does. The one time I used the…
javascriptasked Wallace Maxters 102,340 -
8
votes2
answers157
viewsQ: Why copy the prototype method instead of using directly?
I was confused when I saw a certain javascript library code - the undescore.js. I don’t really remember the code part, but it was something like what I saw. var filter = Array.prototype.filter; var…
-
42
votes2
answers1922
viewsQ: Why do they say that recursive setTimeout is better than setInterval?
I see online a series of articles with titles like: setInterval is bad, which translating would be setInterval is ruin. I saw recommendations to use an anonymous recursive function with a…
-
2
votes3
answers242
viewsA: PHP error - Empty() function
As @rray put it, this "language builder", the empty, does not work with expressions in versions prior to PHP 5.5. My suggestion to make the code simple would be this: if (! ($periodo =…
-
16
votes1
answer8086
viewsQ: What’s the set for in Python?
What is and what is the set in Python? test = set([1, 2, 3]);
pythonasked Wallace Maxters 102,340 -
7
votes2
answers855
viewsQ: What is the use of declaring variables through braces?
In PHP, variables usually have a pattern to follow in their declaration. According to the manual: Variables in PHP are represented by a dollar sign ($) followed by variable name. Variable names in…
-
3
votes1
answer512
viewsA: How to move a file to another folder in Sublime text?
No one has answered yet :( But here I will leave my small solution to this problem in Sublime Text. Moving a file in Sublime Text. Right-click the file you want to move; Select ""; Then renamed the…
sublime-textanswered Wallace Maxters 102,340 -
1
votes4
answers955
viewsA: How does Current function work?
After a long time and even forgetting that question, I found the PHP staff response. If I don’t quite understand the answer, help by editing it. According to a certain [email protected]: Non-iterator…
-
3
votes1
answer512
viewsQ: How to move a file to another folder in Sublime text?
How to move a file to another folder in Sublime text? If I have that structure -- storage/ ---- src/ -- /index.php How could I move index.php for src/storage/index.php? -- storage/ ---- src/ ------…
sublime-textasked Wallace Maxters 102,340 -
7
votes3
answers219
viewsQ: What is the whole argument in Exit() for?
In PHP, when we want to close a script, we usually use the function exit(). When we use strings, it terminates the execution of script and print that string. Example: exit('Stack Overflow'); //…
phpasked Wallace Maxters 102,340 -
1
votes1
answer63
viewsQ: Is it possible to serialize closures in PHP?
It is possible to serialize closures in PHP (even if it is not natively)? Because PHP generates a Fatal Error while trying to do so: $func = function ($a, $b) { return $a + $b; }; serialize($func);…
-
7
votes6
answers47809
viewsQ: How to search for a particular object within an array?
I need to know if determined Array has a objeto with a certain value in its index. I tried to use indexOf, but I was unsuccessful. arr = []; arr.push({id: 1, nome: 'Wallace'}); arr.indexOf({id: 1});…
-
3
votes2
answers126
viewsQ: Syntax error when trying to access static method on object saved in property!
In another of my tests, I noticed that in PHP there is a problem when trying to access the static method of a class, when that class is instantiated in a property of another class; More…
-
1
votes3
answers1212
viewsQ: Why can’t we destroy [using unset in] a static variable?
I was doing some tests with static variables of a class and I came across a Fatal Error. Behold: class Stack { public static $overflow = 'english'; public $user; } Stack::$overflow = 'portuguese';…
-
6
votes3
answers638
viewsQ: How to run PHP in interactive mode?
How do I run php from the command line without using a script as an argument. Example with script: > php index.php I already know how to execute a certain function or code like this: > php -r…
-
26
votes4
answers8564
viewsQ: What good is a gists on the github?
What is the purpose of a gists in the github? Where it differentiates into a repository?
githubasked Wallace Maxters 102,340 -
8
votes2
answers528
viewsQ: What is the difference between new Function and Eval?
What’s the difference between new Function and eval, since the two seem to be doing the same thing? Example with eval: eval('1 + 1'); // 2 Example with new Function: new Function('', 'return…
-
3
votes2
answers348
viewsA: Creating string in PHP
PHP is a weak typing language. It is not possible to set an initial size for the string - at least not natively. What you can do are functions or classes that will do this work. Example: function…
-
4
votes3
answers6632
viewsQ: How do I know if an object is a javascript array (without jquery)?
I wonder how I can identify which object is or is not one array in Javascript. I know that in jQuery there is the function $.isArray. But I’d like to learn how to do it without the jQuery. I tried…
-
3
votes1
answer231
viewsQ: How to create an anonymous (Closure) recursive function?
In php, we can create recursive functions as follows. function quack($quack = 1) { if ($quacks >= 1) { echo "Quack"; $quack--; quack($quacks); } } Or, in case of avoiding problem with "renaming"…
-
4
votes1
answer1274
viewsQ: What is the difference between array_walk and array_map?
In PHP, we have two functions that traverse the array and apply a function determined for each element: array_walk and array_map. Example: $meu_array = array(1, 2, 3); $callback = function ($value)…
-
15
votes2
answers716
viewsQ: What is the name of => operator in PHP used in arrays?
In PHP, when we declare a array directly, we have the operator =>. I know that in PHP we have the ->, that is Separator Object, but I had to give the name to => and could not explain. What…
-
12
votes3
answers1869
viewsQ: Why (1 == true) is "true" and (2 == true) is "false"?
I was explaining to a friend of mine the difference between == and === in PHP and wanted to demonstrate this through the javascript console. I was going to demonstrate to him that in PHP, the…
-
4
votes2
answers318
viewsA: Problems to remove Parent() items with jquery
Use the method closest. He takes exactly the father of the button that contains this class. Do so: $(document).on('click', ".btn-remover", function () {…
-
3
votes4
answers18115
viewsA: Convert Array to String
In php, the function implode does not work for keys, but only for the values of the array. Example: $array = ['site' => 'stackoverlow', 'linguagem' => 'portugues'] implode(',', $array); //…
phpanswered Wallace Maxters 102,340 -
6
votes2
answers1033
viewsQ: How to generate pagination links with limits?
I have a pagination whose results generate large amount of links-numbers. Setting: have 10.000 (ten thousand) records being paginated. The pagination should be 30 in 30; However, links cannot…
phpasked Wallace Maxters 102,340 -
3
votes1
answer1861
viewsA: How can I add elements to a multidimensional array?
From what I understand, you must be wanting to simplify the process. I don’t know if it applies to your case, but one way to do that is by using the references - through the sign &. $test =&…
-
2
votes3
answers2111
viewsA: Convert date format DD/MM/YYYY to YYYY-MM-DD stored in a scan
The @pedroAugust gave a good answer, but what he said can also be done in an object-oriented way. It is a solution that is already PHP itself, through the class DateTime. $datetime =…
mysqlanswered Wallace Maxters 102,340 -
3
votes1
answer149
viewsA: Creating a set of variables in PHP
PHP is a weak typing language. This means that it is not necessary to define a type for the variable. So it’s like you said: it creates the type of variable at startup of the same Example: $int = 1;…
phpanswered Wallace Maxters 102,340 -
1
votes1
answer77
viewsA: Sendmail() BATCH localhost
According to the answer found in SOEN, you could send the same message to multiple recipients as follows: while($row = mysql_fetch_array($result)) { $addresses[] = $row['address']; } $to =…
-
1
votes1
answer222
viewsA: Where Appropriate to Allocate Javascript and CSS Libraries in Cakephp 3
You should put it in the folder webroot of its application, taking into account that the path pointed to the css or js would be declared without "webroot" Example: In html css/default.css points to…
-
23
votes2
answers418
viewsQ: Is it bad practice to use empty interfaces?
I have heard comments that it would be a good idea, when a future implementation can take place. Also heard that it is a bad practice. I know that in PHP, for example, there is an interface called…
-
0
votes3
answers1152
viewsA: How to make an object array have only unique values?
I would like to thank you all for your answers, but I shall give you my reply in order to clarify. How objects work in PHP? First, let’s reinforce some terms: Object is an instance of a class.…
-
2
votes3
answers1152
viewsQ: How to make an object array have only unique values?
If I have a collection with the same object in one array, how could I make this collection with only objects of unique instances? Example: $a = new stdClass; $a->id = 1; $b = $a; // mesmo objeto…
-
1
votes0
answers49
viewsQ: Why does the facebook photo album return an empty array?
I’m using Facebook SDK with Laravel 4. I need to return the images of any user who logs in via Facebook. When I use the user, who is the administrator of the APP on Facebook, the images and albums…
-
4
votes1
answer79
viewsQ: What exactly is the "u" modifier for?
What exactly does the modifier u in the regular expressions of preg_ in PHP? It is recommended to use it whenever processing strings that have accentuated characters? $valor = 'ãẽi ouã';…
-
3
votes2
answers477
viewsA: List every month in Query or PHP?
I don’t know if this helps, but a way to get every month through php - in a very elegant way - would be through the class DatePeriod. Example: $first = DateTime::createFromFormat('d/m', '01/01');…
-
1
votes1
answer249
viewsA: Groups of routes with default values in Laravel
You can simply put a question (?) at the end of {userid}. Therefore, you set the default value for the parameter variable, which represents the id passed in the url. Route::get('/{userid?}',…
-
19
votes2
answers957
viewsQ: Include within class and access to $this, self or Static
I found this little code inside the folder Composer/ClassLoader.php, in a project where I use the composer. /** * Scope isolated include. * * Prevents access to $this/self from included files. */…
phpasked Wallace Maxters 102,340 -
3
votes1
answer1562
viewsQ: How to find conflicting files in GIT?
Let’s say I just made one git pull. Then, for some movement I closed the Terminal (In the Ubuntu, for example) and I haven’t seen which files are marked as CONFLICT. I already learned in a way where…
gitasked Wallace Maxters 102,340