Questions tagged as 'php'

1
answer

Why is it possible to access array indexes with "{}" keys?

In some tests I did with PHP, I saw that it is possible to use keys ( {} ) to access indexes of arrays . Example: $array = ['a' => 1, 'b' => 2, 'c' => ['d' => 4]] echo $array{'c'}{'d'}; // 4 echo $array{'c'}['d']; /...
asked by 04.01.2017 / 20:37
2
answers

How to do a search with Query Builder in Laravel?

I need to display the name of the doctor who requested a patient report, but with Laravel I tried to show this information in View like this: {{laudo->paciente->medico->nome}} Then I received the error message:    Trying to g...
asked by 01.11.2017 / 15:19
2
answers

What is the difference between echo, print, var_export in PHP?

A difference between var_dump and print_r you already have in this answer . But it does not give any details regarding the echo , print and var_export . What is the difference between echo , print , var_...
asked by 11.10.2017 / 07:29
3
answers

How to get the dollar variation of infomoney site?

This code picks up the dollar and euro values of the site. I would also like to get the var (%) which is the 5th column. See the source code and how it works by clicking here <?php if(!$fp=fopen("https://www.infomoney.com.br/mer...
asked by 12.09.2017 / 19:41
1
answer

How to block a range of IPs with php?

I have a function in php, but I would not like it to be executed by people in a certain country, how do I get the php script to block a range of IPs? Example, block the range of US IPs. It is necessary to be able to add more range of IPs....
asked by 01.09.2016 / 05:51
1
answer

Type Object in PHP

I'm practicing some code in PHP when I come across this: <?php $a = (object) ["a" => "b"]; $b = (object) ["a" => "c"]; $y = $a <=> $b; echo $y; $v=[1,2,3] <=> [1,2,3]; echo $v; $a= (object) ["a" => "b"]; $b = (object)...
asked by 14.11.2018 / 22:26
1
answer

Calculation with comma in PHP [duplicate]

I need to multiply the value received from the post form Ex: $ height * $ width * 45; So far so good, but if the user types a comma value, the sum does not happen. I need the sum to happen both ways, and not to show me the result with numbe...
asked by 20.12.2014 / 14:11
2
answers

PDO :: rowCount () returning -1

I have this routine below, which I used without problems with a MySQL database. However, I had to migrate to a SQL Server 2008 database, which was simple. The only problem is that, I do not know why my rowCount() is returning -1...
asked by 08.12.2014 / 18:15
2
answers

PDO vs Doctrine

Work with system development in PHP , more focused on e-commerce . Currently I use PDO to perform my connection to the database, but out of curiosity I decided to search on Doctrine , because when I was developing in C # in NHibernate , w...
asked by 24.03.2016 / 12:54
3
answers

Join arrays by equal keys, but separating values

Scenario (example): I have 2 Arrays , X and Y (dynamically created, individual ): $arX = Array('AAA' => 173.696, 'BBB' => 72.436, 'CCC' => 142.692); $arY = Array('AAA' => 127, 'DDD' => 72.333); Objective: W...
asked by 13.08.2018 / 15:23