Posts by Wallace Maxters • 102,340 points
1,984 posts
-
2
votes2
answers168
viewsA: Display a label while the page is loading
Do it this way: <body> <label id="lblmsg">Carregando...</label> </body> <script> window.onload = callFunction; </script> In that case, window.onload causes this…
javascriptanswered Wallace Maxters 102,340 -
0
votes1
answer49
viewsA: Changing content of a TD
If printing is the problem, then use @print in CSS, so you can hide the buttons only when printing. Example: @media print{ .btnOne, .btnTwo { display:none; } }…
-
0
votes2
answers462
viewsA: print the lines according to the array
If you want to print them in this sequence, why not use the function implode? If I understand that you want to print the indexes, not the values, do it as follows: echo implode('|',…
-
0
votes1
answer522
viewsQ: How to reset the auto_increment value (NO TRUNCATE)?
How can I reset/reset the value of AUTO_INCREMENT in the Mysql, without the use of TRUNCATE? For in some cases it is not possible to use TRUNCATE table in some tables.…
-
1
votes1
answer522
viewsA: How to reset the auto_increment value (NO TRUNCATE)?
Use the ALTER TABLE to do this. It is possible to "reset" a table as follows: DELETE FROM tabela; ALTER TABLE tabela AUTO_INCREMENT = 1; You can also set another starting value for AUTO_INCREMENT…
-
3
votes3
answers2559
viewsQ: Is it possible to add int with str composed of text and numbers in Python?
I asked that question Why in PHP the expression "2 + '6 apples'" is 8? here for finding this behavior strange. And in the case of python? I can convert the string '1' str for 1 int. Example: 1 +…
-
1
votes6
answers392
viewsQ: How to make a explode without returning empty values?
In PHP we can split one string and turn it into array. Example: $url = 'pagina/id/1'; explode('/', $url); Upshot: ['', 'id', '1'] However, if this url had a bar before and after, it would return…
phpasked Wallace Maxters 102,340 -
3
votes6
answers392
viewsA: How to make a explode without returning empty values?
You can do this using the function preg_split PHP, which accepts some flags special for certain cases. In such cases, the flag PREG_SPLIT_NO_EMPTY Behold: preg_split('/\//', $url, -1,…
phpanswered Wallace Maxters 102,340 -
10
votes3
answers15565
viewsQ: Which regular expression can I use to remove double spaces in Javascript or PHP?
What regular expression can I use to remove excess white space? I mean, leave them with the amount of normalized spaces. Example Of: $string = 'Estou no Stack Overflow em Português '; To: $string =…
-
2
votes2
answers335
viewsA: Library that reads text and turns into audio
I have a co-worker of mine who used to use his own Google Tradutor. See how he did in PHP: $google_url =…
-
1
votes4
answers824
viewsA: Regular Expression to get what’s outside of brackets
In javascript, I would do as follows: To get only the word Itaú: 'Itaú [123.456,89]'.replace(/(\[.*\])/g, ''); To get what is inside the brackets (without the brackets): 'Itaú…
regexanswered Wallace Maxters 102,340 -
0
votes1
answer193
viewsA: How to create snippets for __Construct?
Go on Tools > New Snippet. Then paste this sample code: <snippet> <content><![CDATA[ public function __construct(${1:\$argument}) { } ]]></content> <!-- Optional: Set a…
sublime-textanswered Wallace Maxters 102,340 -
0
votes1
answer126
viewsA: System logs alone in any action
I’ve had this problem with codeigniter (and you will always have problems with it) when I set up the session to be saved as cookie. Change the option of cookie for database. I believe the problem is…
-
3
votes2
answers22624
viewsA: How to download from command prompt?
It seems that in the link to Superuser there are some answers, which are not directly by CMD. So I’ll give you my suggestion: PHP PHP can also be used on the command line. We can then read a file…
-
3
votes3
answers1766
viewsA: How do I get the column number of the table where an input I’m writing is?
Use the parent or closest. See with parent. $(".campo").on("focus", function () { var $td = $(this).parent(); console.log($td.index()); //index }) See with closest $(".campo").on("focus", function…
-
4
votes2
answers189
viewsA: Regex - Operator "." - Meta character capture
As already quoted by @mgibsonbr, by default, PHP does not support unicode in regular expressions of preg. In addition to the solution already presented, what can be done is to use regular expression…
-
10
votes12
answers28737
viewsA: What are the ways to iterate an array in PHP (without foreach)?
Another way to do this is by using the function each. She picks up the current pointer from array and turns into another array, containing the value of the index and the value of the index array.…
-
5
votes1
answer1630
viewsQ: Saving a JSON in Database vs Relationship?
When I didn’t know much about the question of database structure and relationship between tables, I used to use JSON or comma-separated data in a given field of any table in the database. In fact, I…
-
13
votes12
answers28737
viewsA: What are the ways to iterate an array in PHP (without foreach)?
I couldn’t help myself without having to give my stick around Another good way to make this iteration of a array, without the foreach, would be with a while, iterating over an instance of…
-
27
votes12
answers28737
viewsQ: What are the ways to iterate an array in PHP (without foreach)?
Before I am censured by the question, notice beforehand that the purpose of it is simply to level curiosity. I know that the foreach is the most suitable means for this. But I would like to know the…
-
4
votes3
answers441
viewsQ: Why is it not very common to use do/while?
I don’t know if this occurs only in PHP, but I realize that it is not very common the use of do/while in the codes written on it. Example: while (ob_get_level() > 0) { ob_end_clean(); } That (I…
-
0
votes1
answer107
viewsA: What is callback called in javascript when it is named (directly in the statement)?
According to this reply in the SOEN, are named as follows: Function declaration or function statement In that case it is the joint declaration of function. Example: function fn() { } named Function…
-
10
votes1
answer12629
viewsQ: Why should we use "IS NOT NULL" instead of "<> NULL"?
I’ve always wondered why we should use IS NOT NULL instead of <> NULL? For when I do as in the second case, no result is found. Example: SELECT * FROM tabela WHERE campo IS NOT NULL Displays…
-
7
votes3
answers187
viewsQ: Omitting Else is a good idea in some cases, right?
I ask myself this question every time I’m coding, because I always worry about leaving my code understandable to other programmers who will contemplate it - and myself, because maybe I won’t…
-
1
votes1
answer107
viewsQ: What is callback called in javascript when it is named (directly in the statement)?
What callback is called in javascript when it is named (directly in the declaration)? Example: Joint declaration of a function: function fn() { console.log(fn); // Imprime fn() return 'do'; } fn();…
-
11
votes8
answers75484
viewsA: Error - "Cannot Modify header information - headers already sent"
As an add-on: What causes many programmers to be surprised by this error is that generally Xampp (or even a common installation between PHP and Apache) comes with the option output_buffering marked…
-
0
votes1
answer55
viewsA: How to use PDO on Eval()
Heed I don’t know why you want to do this, but I already warn in advance that using eval is almost always considered a bad practice. But I’ll answer anyway. Answer For this to work, you have to…
phpanswered Wallace Maxters 102,340 -
0
votes1
answer133
viewsA: Problem with session_set_save_handler
I can jump in and say the problem is Replace Into used in your code. Modify to: if (empty($data)) { $stmt = $mysqli_link->prepare("INSERT INTO session VALUES (?,?,?)");…
-
0
votes4
answers264
viewsA: CSS - Bootstrap min
It is only necessary to download directly into the github, where the repository of bootstrap. https://github.com/twbs/bootstrap/blob/master/dist/css/bootstrap.css To make it easier, here’s the…
-
0
votes3
answers487
viewsA: Problems between loop and ajax
I believe the most correct approach in your case would be: function fnRetorno(j) { if (j >= cidade_nome.length) return; $.post('envia.php', {..., cidade: cidade_nome[j].value}, function () { //…
-
0
votes1
answer57
viewsA: Problems to define new route
Your apache (or whatever server you use) may not be reading yours .htaccess or even there is no .htaccess You said he accesses when you put minha_pasta/index.php/controller/ação To work that way:…
-
2
votes1
answer118
viewsA: Option with CSS button type
Try using the attribute selector to style the option that has the data-url. Behold: select option[data-url]{ font-weight:bold; color:#aaa; text-decoration:underline; background:#eee; border:1px…
-
1
votes1
answer78
viewsA: realpath() function does not accept variable
A little clarification on the function realpath: It will return FALSE should the path of pasta or arquivo does not exist. Example: var_dump(realpath('nao_existe/essa_pasta')); // bool(false) I…
phpanswered Wallace Maxters 102,340 -
0
votes1
answer172
viewsA: Configure Virtualhost in wamp
1 - Open the file %sys%/wamp/bin/apache/conf/httpd.conf 2 - Search by line: # Include conf/extra/httpd-vhosts.conf 3 - Remove the # and save the configuration file. 4 - Restart the Wamp I once…
-
4
votes1
answer215
viewsQ: What is the best way to display in Python? Double asterisk or Math.Pow?
How to best expose in Python? I must use the operator ** or math.pow? Example math.pow: > math.pow(3, 4); #Imprime: 81.0 Example with double asterisk? > 3 ** 4 #Imprime : 81 What I must take…
pythonasked Wallace Maxters 102,340 -
3
votes1
answer180
viewsQ: Is it true that ++$variable (preincrement) is faster than $variable++ (post-increment)?
It is true that ++$variavel is faster than $variavel++? In that reply given in SOEN, we see the following excerpt: ... However pre-incrementing is Almost 10% Faster, which Means that you should…
-
2
votes2
answers944
viewsA: Every class must have a builder
No, you don’t have to. The constructor simply serves to initialize class attributes. The class stdClass for example does not have the method __construct. In some cases, it is better to have a…
phpanswered Wallace Maxters 102,340 -
5
votes2
answers1596
viewsA: Create Javascript Library
I think a good start would be studying the pattern Module. Take an example: var Counter = (function(){ var count = 0; return { count: function() { return count; } , increment: function() { return…
-
1
votes1
answer134
viewsQ: What’s the Splstack class for?
According to the PHP: The Splstack class provides the main functionalities of a stack implemented using a doubly Linked list. What do you mean: The Splstack class provides the key functionalities of…
-
2
votes1
answer226
viewsA: Extend new CI class
First you do this in your Codeigniter configuration file: // exemplo com o seu nome no stackoverlow $config['subclass_prefix'] = 'BILL_'; Then you create the file Bill_Controller.php inside the…
-
0
votes1
answer88
viewsA: Long Polling Doesn’t Do Timestamp GET
If you’re trying to catch the timestamp by the date reply to $.getJSON, then why didn’t you answer with the timestamp? The correct part of your code response should be: $json = json_encode(array(…
-
0
votes2
answers50
viewsA: How not to send many records by clicking often on the button
If the problem is related to ajax requests, another way is the method one. Behold: $('form').one('submit', function() { // Meu ajax é chamado aqui });…
-
2
votes5
answers142
viewsA: what is the best way to create elements?
Another way is by using the tag script with a type different. Example: $(function() { $('#container').append($('#tpl').html()); }); <script…
-
3
votes2
answers400
viewsA: use regex in php explode function
I got what you were wanting this way: $string = '"palavra um" "palavra dois" "palavra três"'; $partes = preg_split('/("|"\s+|\s+")/u', $string, -1, PREG_SPLIT_NO_EMPTY); print_r($partes); Upshot:…
-
1
votes1
answer317
viewsQ: Callable keyword in PHP
The keyword callable was implemented from PHP 5.4. It provides a way to type an argument from a function, requiring the type of argument to be a callback. Example: function minha_funcao($a, callable…
-
0
votes1
answer317
viewsA: Callable keyword in PHP
What is the difference between induction and type made by callable and Closure? The difference is that in the type induction declaration, when we use Closure, we are informing that that function or…
-
2
votes2
answers1206
viewsQ: What does the "?:" operator mean in PHP?
What the operator means ?: in PHP? Example: $a = 0; $b = false; $c = 3; echo $a ?: $b ?: $c; Upshot: 3 What exactly is he doing in the expression above? Is that a ternary? If not, what do you call…
-
1
votes1
answer357
viewsA: Doubt Laravel 5 - Libraries and Functions
Probably the people from Laravel, when developing the version 5, verified possible problems with the conflict of class names and then decided to adopt the namespace so that this would not occur.…
-
4
votes1
answer6661
viewsA: Generate token from string and check generated token
Have you tried using md5? It will generate a 32-character string Behold: echo md5('joãozinho'); // 'a7199fb05606b0d193d79a2dd6c2b537' For verification: $codigo = 'a7199fb05606b0d193d79a2dd6c2b537';…
-
21
votes9
answers12451
viewsA: How to prevent SQL code injection into my PHP code?
A good way to prevent SQL injections is also already using solutions ready for this. Perhaps the use of Frameworks Full Stacks - that already have several solutions ready for the programmer, from…