Posts by Wallace Maxters • 102,340 points
1,984 posts
-
11
votes3
answers181
viewsQ: Why in Javascript, 7 (a number) is not an instance of Number?
When we do the following test below, it is returned false. console.log(7 instanceof Number); // FALSE However, in the second test, it is returned true. var number = new Number('3');…
javascriptasked Wallace Maxters 102,340 -
8
votes2
answers5412
viewsA: What is Lazy Loading and Eager Loading?
A classic example of this in PHP would be given with Laravel. For example: If we have a User model that relates to multiple Purchases, we could access these purchases like this $usuarios =…
-
4
votes2
answers3951
viewsQ: What is the difference between mouseleave and mouseout?
In jQuery, what is the difference between mouseleave and mouseout? The two events seem to do the same thing!
jqueryasked Wallace Maxters 102,340 -
1
votes1
answer29
viewsA: How to use reversed function in this case of jquery?
From what I understand, you want to use what would be the inverse of mouseenter (executes an event when the mouse is placed on an element). Use the event mouseleave It executes an action when the…
jqueryanswered Wallace Maxters 102,340 -
5
votes2
answers1570
viewsQ: What is this __php_incomplete_class?
I always end up discovering a lot of crazy in this language that I love: PHP! What would be this mysterious class __PHP_Incomplete_Class? I "found" her accidentally, when I gave a…
phpasked Wallace Maxters 102,340 -
5
votes2
answers4997
viewsQ: What are the differences between __autoload and spl_autoload_register?
In php, we have two methods of making one autoload class: __autoload function Example: function __autoload($class_name) { require_once $class_name . '.php'; } $obj = new MyClass1(); $obj2 = new…
-
0
votes2
answers474
viewsQ: Incomplete week name on strftime return
I am trying to print the day of the week, according to a certain timestamp, with the function strftime. I’m doing it this way: setlocale(LC_ALL, 'pt_BR', 'pt_BR.iso-8859-1', 'pt_BR.utf-8',…
-
2
votes1
answer75
viewsQ: In Laravel, which file is indicated to use Macrotraits?
In Laravel, some classes use the trait MacroableTrait. Through this trait it is possible to create definitions such as: HTML::macro('urlQuery', function () { // Faça alguma coisa aqui });…
-
2
votes1
answer157
viewsQ: What is this __set_state that appears in var_export?
The var_export serves to export the data of a given value as a valid php code. However, when I use it on a class object stdClass, it returns me the following code: stdClass::__set_state(array( 'one'…
phpasked Wallace Maxters 102,340 -
2
votes1
answer64
viewsQ: How to var_export export export array in short syntax
According to the PHP Handbook, about the function var_export var_export() gets structured information about a given variable. It is similar to var_dump() with one exception: the returned…
phpasked Wallace Maxters 102,340 -
3
votes1
answer161
viewsQ: Because in PHP, some predefined constants are case-insensitive?
Because, in the PHP, some predefined constants are case-insensitive (do not differentiate capital letters from minuscules) and others are not? Example 1: echo __FILE__; // index.php echo __file__;…
-
4
votes3
answers109
viewsQ: In PHP, is NULL a constant or a keyword?
In PHP, NULL is a constant or a keyword? I’ve heard it’s a constant, but it looks like the keyword behavior of PHP (that do not differentiate capital from minuscule)? Example: echo NULL; echo null;…
-
0
votes3
answers485
viewsA: Make an ORDER in Mysql from another TABLE
As it comes to two tables, you would have to make one JOIN. I believe you can do it this way: SELECT users.* FROM users JOIN chat ON chat.id_de = users.id WHERE (id = '$id') OR (id IN (SELECT…
-
1
votes3
answers179
viewsA: Why ismysqli_ better thanmysql_?
By title placing in the manual on the library mysqli, I answer very simply: Whymysqli_ is better than mysql_? Because according to the manual, it’s: Improved Mysql extension Look at this one link…
-
4
votes6
answers3314
viewsQ: Get the local time in javascript with zeros?
I’m trying to get local time and minute in javascript. The first way I tried was this: date = new Date; date.getHours() + ':' + date.getMinutes() // 10:5 But for the time of 10 hours and 05 minutes,…
-
6
votes1
answer332
viewsQ: How do I make the sublime text mark a word as keyword?
I like to use sublime text to develop some things in php. But there’s one thing that hasn’t been implemented yet. When I create a trait, the sublime text not "color" the keyword trait as expected.…
-
1
votes1
answer2177
viewsA: Sublime, override/replace codes
If it is in one file, you can use the shortcut CTRL+D, after you have selected the color. From there, you press until all is selected. This will make that, when you type, all occurrences of #a10f2b…
sublime-text-2answered Wallace Maxters 102,340 -
29
votes3
answers847
viewsQ: Does merging PHP files into one only increase performance?
I get the impression that every time I execute the command dump-autoload to generate the autoload of the classes via composer, an archive bootstrap/compiled.php is created. Within it, there seems to…
-
2
votes1
answer3945
viewsA: Cannot use Object of type stdClass as array
Try this $query_check_user_name->fetchAll(PDO::FETCH_ASSOC); PHP usually returns this error when you have any object (as long as you don’t implement the interface ArrayAccess) and tries to access…
-
4
votes2
answers184
viewsQ: How can I sort by line size in Sublime Text?
I wonder if there is any way to sort the line by its size in the Sublime Text. 'Cause I got a code like that: use ArrayAccess; use ArrayIterator; use IteratorAggregate; use Countable; use Closure;…
sublime-textasked Wallace Maxters 102,340 -
0
votes1
answer361
viewsQ: Laravel - How to make a Try/catch in the view?
Is there any way to make some try/catch in a view of Laravel 4? How could I implement in the syntax of blade? I’d like something like: @try <div class="laravel test"> {{ $usuario->nome }}…
-
4
votes1
answer80
viewsQ: What are the advantages of using Splfixedarray instead of an array?
What are the advantages of using Splfixedarray instead of an array? What are the advantages of fixing a value to an "array" (in PHP) ? Example with array: $arr = array(); $arr[0] = 'Stack'; $arr[1]…
-
1
votes1
answer65
viewsQ: At which points does Arrayaccess not resemble the native PHP array?
I know that the ArrayAccess exposes an access interface to some elements of the object as if it were a array Example: class ListObject implements ArrayAccess{ protected $storage; public function…
-
4
votes3
answers1614
viewsA: How to increase session time in phpMyAdmin on Ubuntu?
Oops! It seems that the solution was also in itself phpmyadmin :) See the image: I just need to change the value of "Login cookie validity" to a higher number.…
-
2
votes3
answers1614
viewsQ: How to increase session time in phpMyAdmin on Ubuntu?
When I’m developing a system, I usually leave my phpmyadmin open. Then, when a while goes by, this message below appears: How can I set up my phpmyadmin so that I can increase that session time (or…
-
15
votes3
answers14534
viewsQ: What is the INDEX index in Mysql for?
What is the content for INDEX in Mysql? ALTER TABLE `tabela` ADD INDEX `tabela_id_index` (`tabela_id` ASC);
-
1
votes2
answers68
viewsA: How to check if a class is using a Trait?
Another way to find out if the trait exists in a class is through the method RelectionClass::getTraits Behold: $reflection = new ReflectionClass('MyClass'); if (in_array($trait,…
-
4
votes2
answers68
viewsQ: How to check if a class is using a Trait?
How can we know if a class uses a Trait? For example: trait Setter { protected $vars = []; public function __set($key, $value) { $this->vars[$key] = $value; } } class User { use Setter; } $user =…
-
30
votes2
answers4104
viewsQ: When should I use Inheritance, Abstract Class, Interface, or a Trait?
From PHP 5.4 we have the Trait, that "are mechanisms that help (and greatly) the reuse of code, and serve perfectly to solve the problem of lack of multiple inheritance". Example of Abastrata Class…
-
4
votes1
answer397
viewsQ: In PHP, is there any way to import only one function from a given file?
I see that in Python, we can import only one function from a particular module, without having to load it all. In addition to this being great to avoid function name conflicts. Example: #funcs.py…
-
1
votes0
answers97
viewsQ: In Laravel 4, how do I convert the Model output to XML?
In Laravel, how could I transform the following result below to an XML structure? $usuarios = Usuario::with('nivel')->where(['status' => 1])->get()->toArray(); // Resultado: [ 'usuarios'…
-
2
votes1
answer232
viewsQ: Why should I use File::copy, if PHP already has copy?
I am using the Laravel in various projects that I use. I needed to copy a particular file from one location to another, and I saw in the Laravel documentation that I should use File::copy(). Out of…
-
3
votes1
answer2440
viewsQ: Should I use DIRECTORY_SEPARATOR or BARRA (/)?
I often fiddle with frameworks source code, as in the case of Laravel to see how the structures are made. I noticed something interesting in Laravel 4 in relation to the Laravel 3. In the Laravel 3,…
-
2
votes2
answers120
viewsA: Difference between [ID="MAIN"] and #MAIN
# (Sharp) Already a character for representation of element ID by default in css. [ID="MAIN"] (Attribute Selector) It means that you are using a CSS3 selector type, where you can "pick up" an…
cssanswered Wallace Maxters 102,340 -
2
votes2
answers958
viewsQ: preg_split to separate words, but ignoring some
I need a regular expression that splits a string, more specifically a full name of a person, and transforms it into an array of words. $string = "Wallace de Souza Vizerra"; $array =…
-
6
votes3
answers14381
viewsQ: Are there interfaces in python?
In languages like PHP and Java, there are interfaces, which, when implemented in a class, requires it to contain the methods of this interface in the same way as they were declared. Example in PHP:…
-
25
votes5
answers63261
viewsQ: How to clean the console in Python?
I am an Operating System user Ubuntu and when I want to clean the terminal, I use the command clear. >>> clear However, in the Python, how could I do to clear the terminal, when I use it on…
-
1
votes0
answers54
viewsQ: Trying to access browserconfig.xml could be some kind of attack?
Here in the company where I work, we put in a certain system, made in Laravel 4, a system of sending emails every time some kind of error occurs in requests. We started to distrust some activities,…
-
4
votes3
answers476
viewsQ: How do I convert snake_case to camelCase (and vice versa) in Python?
How could I, in any way pythonic possible, convert a string snake_case for camelCase ? Example: snake1 = 'minha_string_snake_case' # minhaStringSnakeCase snake2 = '_teste_string' # _TestString…
-
16
votes2
answers7005
viewsQ: What are the differences between die, Exit and __halt_compiler?
What are the main differences between die, exit and __halt_compiler?
-
0
votes2
answers50
viewsA: generate query dynamically with Union
I believe to put each query mounted in an array and then use the function implode would also be a way to unite your consultations. $wheres[] = 'SELECT * FROM x'; $wheres[] = 'SELECT * FROM y';…
-
1
votes2
answers116
viewsQ: What is the appropriate http code to respond to the contents of an image?
Well, the question is quite straightforward. I want to use PHP to answer the content of an image. However, I would like to know if the http status type will have any impact on the client (for…
-
1
votes2
answers773
viewsA: PHP / Codeigniter - How to convert image to byte array?
The answer from @Felipedouradinho was nice. But, if you want to create an array of bytes, you would have to do so. $filename = "image.png"; $file = fopen($filename, "rb"); $tamanho_do_buffer = 4096;…
-
6
votes1
answer1174
viewsA: Copying table in Mysql
If you want to create a new table based on an existing one, there is a very simple way to do: CREATE TABLE nova_tabela SELECT * FROM tabela_a_copiar There are some remarks about the use of this. I…
mysqlanswered Wallace Maxters 102,340 -
5
votes2
answers7137
viewsQ: What does KWARGS in Python mean?
I know that, in Python, we can define in a function something similar to what they call "named Parameters", ie, "named parameters". def my_func(**kwargs): pass my_func(nome="Stack Overflow",…
-
4
votes2
answers395
viewsQ: How to verify if a constant exists in the class or in a namespace?
In PHP, to check if a constant exists we use the function defined. As below, for the two cases of constant declaration: const MY_TEST_1 = 'my test 1'; define('MY_TEST_2', 'my test 2');…
-
5
votes3
answers392
viewsQ: Why in Python can we define an index of a Dict as a Tuple?
I noticed that in Python, we can add values like tuple as an index of a dict (dictionary). Example: test = {} test[(1, 2, 3)] = ("um", "dois", "tres") print test // {(1, 2, 3): ('um', 'dois',…
-
6
votes2
answers11472
viewsA: Just grab a div from another page via jQuery
I would use the method .find in the content of the reply to your request. It may seem strange at first, it works perfectly. Behold: $.ajax({ url: 'http://agenciaroadie.com.br/loja.php', type: 'GET',…
-
2
votes1
answer51
viewsA: Header does not work
Friend, the function header PHP only works when it is placed before any output to the client. That is, codes like this below will result in error: <?php $meus_dados = [1, 2, 3];…
-
3
votes1
answer278
viewsA: How to update the pivot in LARAVEL 4 using the UPDATE method?
Guys, I ended up discovering, by "navigating" the source code of the class Illuminate\Database\Eloquent\Relations\BelongsToMany. There, there is a method called updateExistingPivot. Example:…