Questions tagged as 'php'

1
answer

What is the best practice for a "back page" link?

Would you like to know the best practice for that default button / link in the applications? Today I use href="javascript:history.back();" but there are some considerations that over time I came across, are 3 doubts : INCOMPATIBILIT...
asked by 25.10.2015 / 14:35
2
answers

What would be the route model for an API Rest in more complex operations?

I researched a little about the REST API model, but among many questions I had, I had one that is essentially important. The staff always gave examples of model routes similar to this: https://api.dominio.com.br/account[/{id}] GET -> ob...
asked by 03.09.2017 / 02:16
2
answers

How to calculate the time of each year between two dates?

I need to get two dates and calculate the time period of each year in isolation . For example: between dates 12/06/2012 and 12/06/2017 the correct output would be: 2012 = 5 meses e 12 dias 2013 = 12 meses 2014 = 12 meses 2015 =...
asked by 19.08.2017 / 22:07
1
answer

How to get the multiple of some value in PHP?

I need to do a search on the database and according to the value found within a range of values should return a specific value. For example, if you find values from 1 to 4, you should return 1, finding from 5 to 8, you should return 2. The...
asked by 01.01.2014 / 15:28
2
answers

Authentication with two different tables

I need to do two authentications, one for other clients for admins, so I have to have two instances of auth; how to do this in Laravel, where do I have a client table and another admin table?     
asked by 14.01.2014 / 04:31
2
answers

Which one performs better? For or Foreach + Range?

In the two ways below, which one performs better? For : for( $x=1; $x < 31; $x++ ) echo $x . PHP_EOL; Foreach + range : foreach( range(1,30) as $x ) echo $x . PHP_EOL; I know the difference will proba...
asked by 08.05.2015 / 21:03
3
answers

Is it a good idea to declare variables with accents?

I was taking a look at the PHP Manual on the variables . There I found a snippet of code that left me with the "back foot". $täyte = 'mansikka'; // válido; 'ä' é um caracter ASCII (extendido) 228 I always see in php beginner tutorials t...
asked by 01.09.2015 / 17:57
3
answers

How to use double and single quotation marks?

Let's imagine the following example : $color = "red"; echo ("<button onclick='change_background("/red"/);'>$color</button>"); What should I use when I have 3 levels using the example in change_background("/red"/); ?...
asked by 30.09.2015 / 14:07
1
answer

"Referer" or "Referrer"? Is this a misspelling or is it correct?

Honestly, I have a tremendous doubt right now. I just gave this answer here in stackoverflow: link In this answer, I teach that, to refer to the previous page, we should use the variable $_SERVER['HTTP_REFERER'] . I even did tests...
asked by 14.04.2016 / 22:04
2
answers

How to hide the source code of the PHP file?

I developed a system and the place where I work wants to distribute it by all the branches, I do not intend to charge for it while I work there, but if one day I leave yes. The system is made in PHP, so I would like to know if there is any wa...
asked by 31.05.2014 / 03:25