Questions tagged as 'php'

3
answers

Verify Connection Existence with MySQL in PHP

I came across this question recently, how to check if there is an open connection to mysql? Everyone knows that in order to use mysql_real_escape_string need to have a certain connection, so I wanted to check if there is one, if yes then...
asked by 10.04.2014 / 15:49
2
answers

How to use class variable as default value in php functions?

class Teste(){ public variavel; public variavela; function teste($parametro=$this->variavel, $parametro2->$this->variavela){ // code } } I get the following error:    Parse error: syntax error, unexpected '$ this' (T_V...
asked by 09.02.2015 / 20:39
3
answers

Symbol "-" in php [duplicate]

When I used PHPmailer I used (without knowing why) the symbol "->" in $mail->AddAdress(... , for example. Now asking a question in W3schools ( http://www.w3schools.com/php/php_mysql_connect.asp ) I saw this little set "- >" a...
asked by 12.10.2015 / 04:41
3
answers

I need a function to add br under certain conditions [duplicate]

I want a function that adds the <br> tag when the text has no spacing, I made a Fiddle with the problem: link . This function can be done in JavaScript or PHP. <div class="post"> <p>kkkkkkkkkkkkkkkkkkkkkkkkkkkkk...
asked by 29.10.2015 / 20:00
2
answers

Format echo number with 'k', 'kk', and so on

In several places on the internet you can view number formatting such as "150k", "1kk". Most people know that 150k is 150,000 and 1kk is 1,000,000. EXAMPLE: ThatwouldbeusefulbecausesometimesImovewithbignumbers,whichaestheticallyisbad,becauses...
asked by 18.02.2015 / 04:33
5
answers

Hide the last 4 numbers of a string [closed]

I have a string of the value 187.10.61.291 , I want a function that takes the last 4 numbers and transforms it into * . Example of expected result:    192.1**.*.* or 192.16*.**.* or 192.168.***.* or 19...
asked by 30.09.2016 / 04:45
3
answers

Turn m: s in seconds

How to transform a value into seconds? For example: 01:32, in case it would be 92 seconds. I would like to do this in php, I already searched the net but found nothing.     
asked by 14.04.2018 / 02:57
4
answers

Check if array () is empty with PHP

I have a form with several fields. To get the values, I'm doing it this way (I put only the first 4): <?php $dados[0] = $_POST["TipoSanguineo"]; $dados[1] = $_POST["PlanoSaude"]; $dados[2] = $_POST["CalendarioVacinal"]; $dados[3] =...
asked by 18.09.2018 / 17:44
4
answers

How to generate random numbers for Draw? [closed]

I need to generate numbers for a promotion, these numbers should range from 0 to 99999. How can I distribute these numbers randomly and equitably, without repeating numbers already distributed?     
asked by 24.10.2016 / 23:44
6
answers

How to calculate percentage?

I have a variable that dynamically receives from the database, a floating number that is the percentage to be taken out of a given value. How do I get this percentage out of a value? For example: $total = 4000; $pctm = 30.00; $valor_descont...
asked by 21.09.2015 / 21:51