Posts by Wallace Maxters • 102,340 points
1,984 posts
-
4
votes1
answer124
viewsQ: How to discover the CSV delimiter by PHP?
A CSV file can vary the delimiters. I’ve seen it used ; (point-and-comma), , (comma) and up to \t (tab). In PHP, I know it is possible to capture CSV values by informing the delimiter: $delimitador…
-
0
votes1
answer117
viewsA: pagination in Vue js
The behavior I expected him to have was to navigate to the new url with the new parameter and have it assemble the component again, but it just navigates and I have to give a F5 to show the new…
-
1
votes1
answer40
viewsA: How to prevent Python from considering very close numbers equal?
This seems to be a precision problem of float. When running Python termninal and paste the value 2.50000000000000001, is returned 2.5. To solve, use the class Decimal. from decimal import Decimal x…
pythonanswered Wallace Maxters 102,340 -
1
votes0
answers63
viewsQ: How does the inline-size property work?
I was snooping around the browser console tweaking an element, and I noticed that Google Chrome completed a property called inline-size. I don’t remember seeing this property before, but I did…
-
5
votes0
answers62
viewsQ: Is there any way to specify scroll-behavior runtime: Smooth?
The estate scroll-behavior: smooth allows you to change the behavior of the scroll to be smoother. Example: #scroll{ overflow: auto; height: 600px; width: 100%; scroll-behavior: smooth } #a, #b {…
cssasked Wallace Maxters 102,340 -
2
votes2
answers137
viewsA: Function returning another function
someone could explain to me how the second function is returning to function f? The function funcao is returning f, which is a function. When you do: variavel = funcao()("OI") print(variavel) is the…
-
0
votes1
answer36
viewsA: Error using . length in AJAX response
The problem is generated because its array has no "regular" indexes for it to be returned as an array in JSON. You started counting the array through 1 and not 0. If you have this array below, it…
-
2
votes1
answer127
viewsQ: Like reading a JSON on Harbour?
In PHP, to interpret a JSON file for the language, we can use the function json_decode. Already in Javascript, we can use JSON.parse. What about Harbour? Is there a role to interpret JSON? Example:…
-
2
votes1
answer33
viewsA: Pq o res.innerHTML does not update to "All right so far"
You are wearing this: let res = document.getElementById('div#res'); That is wrong! The value div#res is a selector. This would work properly if you were using the function document.querySelector. To…
javascriptanswered Wallace Maxters 102,340 -
2
votes1
answer42
viewsQ: How to format a date in Harbour?
I’m learning the language Harbour. I’m seeing how this language works with dates. PROCEDURE MAIN() LOCAL date := Date() ? date RETURN This is returning me: 02/10/21 How could I do to format this…
harbourasked Wallace Maxters 102,340 -
1
votes0
answers33
viewsQ: How can I run Harbour on Apache?
For some languages to work in Apache, such as PERL or PHP, we can install the mod_perl or the mod_php. In PHP we still have the PHP FPM option. Already in the case of Python, we can use WSGI. What…
-
0
votes1
answer38
viewsA: Relating 3 Standard Tables
Assuming you understand how to relate models in Laravel correctly, you should use Has Many Thogheter. Thus: class User { public function orders() { return $this->hasManyThrough(Order::class,…
-
8
votes1
answer215
viewsQ: What is IEEE 754?
Here on the site, we have several examples of questions that talk about "problems" related to float or double, generally about the inaccuracy of the values returned in calculations, as these below:…
terminologyasked Wallace Maxters 102,340 -
1
votes1
answer27
viewsA: How to just get the XML numbers
First detail: the function simplexml_load_file generates an instance called SimpleXmlElement. And I’m telling you... this class is pretty boring to move. You use the separator Object (the ->)…
-
1
votes1
answer32
viewsA: When I use a certain namespace class, do I need to use require?
... every time I use namespace I have to do the require of the file where the classes are, or I just have to do it when I’m not using autoload? You just have to use the functions require,…
-
5
votes3
answers358
viewsQ: How to generate random hexadecimal colors with Javascript?
In this question, teach how generate random colors through PHP. How to do this in Javascript?
-
8
votes2
answers141
viewsQ: What is the difference between the functions Rand, mt_rand, random_int?
To generate random numbers with PHP, there are some functions. Among them rand, and mt_rand. Until recently, I used the mt_rand, 'cause as the documentation says, she’s a "improved random number…
-
2
votes1
answer44
viewsA: How to convert and run a formula in PHP?
To process a string in PHP and turn it into a "real" result, you may need to walk a path, let’s say, complicated... Eval, one possibility, but I’d rule it out... First, it is likely that the easiest…
phpanswered Wallace Maxters 102,340 -
2
votes1
answer44
viewsA: How to create a template system with PHP slots/sections?
Quite simply, I imagine you want to build a layout system and template slots in PHP. A long time ago I made a lib called Phplegends/View that has it. Only that, in a very simplified way, you can do…
-
0
votes1
answer129
viewsA: How do PHP 8 attributes work?
What is the purpose of the attributes? Attributes are intended to change the behavior of the method/class, or are they just extra data? According to the documentation: Attributes allow you to add…
-
3
votes2
answers139
viewsA: How to check if there is a property in an object?
Consideration of the title The title of the question is how to check if there is a property in the array?, but the type shown in the question is not a Array, and yes a Object. Solution 1 Maybe you…
javascriptanswered Wallace Maxters 102,340 -
1
votes1
answer31
viewsA: Laravel 8.12: syntax error, Unexpected 'min' (T_STRING), expecting ')'
See the excerpt from this line you wrote: {{ assets( plugins/bootstrap/dist/css/bootstrap.min.css) }} This is a syntax error. You need to put the assets as string. Thus: {{…
laravelanswered Wallace Maxters 102,340 -
4
votes3
answers169
viewsQ: What is the loading="Lazy" attribute for images and iframes?
To help with my site’s SEO, I use an extension in Chrome called Meta SEO Inspector. After an update, she began to indicate that my site needed to add the attribute loading="lazy" in tags…
-
0
votes1
answer35
viewsA: to sort an array of objects within an array of objects
You can use a callback in the method Array.sort. This accepts a callback. In that callback we can return 1, 0 or -1. -1 changes the position of the item to the first, 1 for the final, and 0 holds in…
javascriptanswered Wallace Maxters 102,340 -
0
votes2
answers41
viewsA: Do not display variable value in the Laravel view
It has already been answered, but you could also use a simpler way, using @php. Behold: @foreach ($respostas as $resposta) @if($reclamacao->id == $resposta->reclamacao_id)…
-
1
votes1
answer227
viewsA: How to auto complete HTML in . tpl files in Vscode?
One of the options is you include a specific configuration in your file settings.json. There are two ways you can do this. Accessing the VS CODE "Preferences" screen To access VS Code preferences,…
visual-studio-codeanswered Wallace Maxters 102,340 -
4
votes1
answer179
viewsQ: What are the main differences between Arrow Function and Closures (anonymous functions) in PHP?
In version 7.4 of PHP, it was implemented Arrow Functions. Example: $double = fn($x) => $x * 2; var_dump($double(4)); // int(8) Which could be done as follows in previous versions: $double =…
-
0
votes2
answers34
viewsA: How to make buttons have the color defined in css when selecting Row in a datatable
I believe it is simple. Just add the .btn as "heir" to his tr.selected and apply the style in it. Thus: table.dataTable tbody tr.selected .btn { color: inherit; } The inherit will cause the same…
-
8
votes2
answers334
viewsQ: What is a Murmurhash?
I saw that is being programmed for next version of PHP 8.1 the implementation of Murmurhash. I had never heard of it. I would like to know what it is.…
hashasked Wallace Maxters 102,340 -
1
votes1
answer106
viewsA: Meta tags, is there to set the image of the site?
Open Graph Protocol As already stated in the comments, the mechanism will depend more on who uses it than it will be a standard in HTML. But there are some patterns used by the web. On my websites,…
-
7
votes1
answer102
viewsQ: What are the differences between Decorators and Attributes?
I asked a question recently about the use of attributes that was introduced in PHP 8. Attributes to me end up not sounding like novelty, because I remember seeing something like that when I worked…
-
5
votes1
answer129
viewsQ: How do PHP 8 attributes work?
In PHP 8, the attributions, which can be used in classes or methods. Example: namespace MyExample; use Attribute; #[Attribute] class MyAttribute { const VALUE = 'value'; private $value; public…
-
3
votes1
answer61
viewsQ: Is there a difference between list and "Symmetric array destructuring"?
I was looking for a new syntax, which was implemented in PHP 7.1, called Symmetric array destructuring, in accordance with the PHP documentation. Basically, this allows "unstructuring" an array,…
-
1
votes1
answer46
viewsQ: How to know if a variable has already been defined in Bash?
I have an application that runs from a script sh. I have in this script defined some variables, where I use export to be accessed internally by the application. However, now I only need to define…
bashasked Wallace Maxters 102,340 -
9
votes2
answers304
viewsQ: What are the differences between match and switch in PHP8?
PHP 8 looks like have already been launched, with a series of changes and new things. Among the changes, they created the expression match. I saw that she reminds a little of the old and traditional…
-
3
votes1
answer203
viewsQ: Is there a data limit that can be passed in Websocket.send?
I built a server to implement the Websocket HTML5. In this implementation, I always send and receive data in the format JSON. But I have the following question: There is a limit size to be passed in…
-
2
votes1
answer900
viewsQ: Why is the operator "?:" called Elvis Operator?
In PHP, I usually use some expressions to simplify the declaration of a variable conditionally, via the operator ?:. Example: function testing($usuario = null) { $usuario ?: $usuario =…
-
4
votes1
answer38
viewsQ: How to return only the last commit date?
I know if I use the remote git log I can see commit ids in my repository and if I use git rev-parse HEAD, I can see the name of the last commit. But I needed to return only the date information of…
-
3
votes1
answer133
viewsQ: What is the use of "." (dot) in PHP’s ltrim, rtrim and Trim functions?
I was here doing a feature, where I needed to remove some characters from the beginning of a string, and I wasn’t really in the mood to use regex for that. I tried to use the function ltrim, since…
-
1
votes1
answer41
viewsA: How to sort an array by two different indices?
First detail is that your arrayis with some errors. You have doubled the key score here: array("nome" => "Ricardo", "score" => "200", "score" => "8" ), Second detail is that, to make this…
-
10
votes2
answers206
viewsA: When to use GIT ADD?
Short answer: Yes, the git add needs to be used. It not only serves to add files that are not yet part of the repository, but also to indicate which file modifications will enter the next commit.…
gitanswered Wallace Maxters 102,340 -
3
votes2
answers48
viewsA: Is it possible to show a div after a certain time that you click?
You can use the function setTimeout. This will cause a particular function to be executed after x millisecond. Take the example: document.querySelector('#clique-aqui').addEventListener('click',…
-
6
votes4
answers310
viewsQ: What is the MQTT protocol?
These days I’ve heard of a communication protocol called MQTT. For me it sounded like news and I would like to ask some questions: What is the MQTT? He uses TCP? It has some difference in relation…
-
2
votes5
answers1493
viewsA: How to create a function to validate time in PHP
If you are considering only hours of 00:00 and 23:59, you can simply use the method DateTime::createFromFormat or function, which is the nickname for this first, date_create_from_format Thus:…
phpanswered Wallace Maxters 102,340 -
4
votes4
answers951
viewsA: How to make a "read more" and a "read less" button in a text that comes dynamically from the database with Pure Javascript?
You can do with the following steps: Check if the text passes the desired size with a if in PHP. Limit text to the desired size within a div if the size passes the PHP limit. Create a div with the…
-
0
votes2
answers317
viewsA: How do I use the same session in the Standard for all subdomains?
According to that answer SOEN, just modify the file config/session.php Look for the following line: 'domain' => env('SESSION_DOMAIN', null), Then put .i9technology.com.br. A note in the reply…
laravelanswered Wallace Maxters 102,340 -
2
votes1
answer80
viewsA: PHP returning an invalid JSON
I believe the mistake lies in this line $jsonGeral = stripslashes(json_encode($this->jsonGeral)); Update after the comment In case, how jsonGeral if it is an object, use only the function…
-
5
votes1
answer375
viewsQ: How to cancel/interrupt a request made with Axios?
Generally, I usually make some AJAX calls with the library Axios. Those days I needed a resource, where I could interrupt a certain request already started, but did not know how to do. Is there any…
-
1
votes1
answer37
viewsA: Action after the end of the foreach
To perform an action after the foreach, just put the code at the end. foreach ($array as $key => $value) { // Código dentro do loop } // Código depois do foreach echo "Foreach finalizado com…
-
7
votes2
answers241
viewsQ: Is there a difference between Number and parseFloat?
When I need to turn a string into a number in Javascript, I can use both the object Number as the function parseFloat. Example: var numero = "1.5"; console.log(Number(numero));…