Questions tagged as 'php'

3
answers

PHP and MySQL, how thousands of connections are processed at the same time?

Using PHP and MySQL as an example, let's assume that there are 1000 connections (clients) accessing the site and using functions that open connection to MySQL and make queries. How do PHP and MySQL process so many connections and queries at the...
asked by 24.05.2014 / 18:06
4
answers

How to generate indented code?

How to print indented code when I give echo to PHP? let's say the structure looks like this: echo '<div>'. '<table>'. '<tr>'. '<td>'. '</td>'. '</tr>'....
asked by 21.07.2015 / 22:41
3
answers

How to compare dates in PHP?

I would like to know what function I use to compare two dates and return to larger ones. I have a form for HR registration in which the user will register their professional experiences being that the date of entry into employment can not be...
asked by 22.09.2014 / 20:55
2
answers

How does PHP foreach work?

To clarify, this question is not about when foreach is used or what its differences are for other repetition loops , but rather on the operation of foreach itself. In documentation , little is said about exactly how fore...
asked by 21.09.2018 / 18:31
2
answers

How to simplify the following IF in PHP?

I had to do a check to concatenate content to a variable, but I think the service got a little "hog" and wanted to see if anyone could help me simplify this check. if($IdUserOnline2){ $IdsInteracoes .= implode(',',$IdUserOnline2); if($...
asked by 20.03.2014 / 18:24
4
answers

Is there a Site / API for hosting photos on the web?

I wonder if there are any APIs that allow you to host photos on the web. Example: cloud.push(arquivo, callback, fail); I'm going to use this API to enable users to host images for profile photo, etc. (I currently do this using base64, bu...
asked by 25.02.2014 / 02:50
7
answers

How to know if the form is sent

How do I know when the form is submitted and the input fields are blank? I was asked to isset to perform this action but I did not understand the right use of isset     
asked by 25.09.2015 / 23:00
1
answer

How to implement memoization in a PHP function?

I saw today at answer the following code: function fibonacci($n) { $a = 0; $b = 1; $c = 1; for ($i = 1; $i < $n ; $i++) { $c = $a + $b; $a = $b; $b = $c; } return $c; } echo fibonacci(100)...
asked by 15.12.2015 / 17:45
2
answers

Getters and Setters can only "walk" together?

I am studying object orientation and am having some questions on the encapsulation part. For example: Class Url { private $url; public function setUrl($url) { if (filter_var($url, FILTER_VALIDATE_URL)) { $this -&...
asked by 21.12.2014 / 07:30
4
answers

Script returning Parse error: syntax error, unexpected end of file

When adding this method to PHP code <?php function meuMetodo($a, $b) { $c = $a + $b; if ($c > 1) { return TRUE; } else { return $c; } ?> This error occurs:    Parse error: syntax error, unexpected end of fil...
asked by 17.02.2015 / 18:29