Questions tagged as 'php'

3
answers

How to check if there is a certain number in a php variable?

So I was giving a searched, looking for some function of php that verifies if a certain number exists inside a variable. And I found the preg_match (). code: $numeros = "1 2 3 4 5 6 7 8 9"; preg_match(1,$numeros); Error:   ...
asked by 25.01.2017 / 13:51
2
answers

Error "expects parameter 1 to be mysqli, string given in"

I am creating an insert form to register, but when I click the button it is presenting me an error:    Warning: mysqli_query () expects parameter 1 to be mysqli, string given in C: \ wamp64 \ www \ Project Beauty and Harmony \ Beauty and Harm...
asked by 05.01.2017 / 01:39
6
answers

How to leave the average in red?

How do I make the average result turn red if its value is less than 20? Follow the code: <?php function media($p1,$p2,$p3) { $resultado = ($p1 + $p2 + $p3)/3; return $resultado; } $aluno[0]["nome"] = "Ryan"; $aluno[0]["m...
asked by 30.01.2014 / 21:38
5
answers

JSON accent

I'm having an accent problem when I start JSON. If I use characters like ã, õ, ô, ç, some codes appear. I do not know if it influences, but the column is Collation "utf8_general_ci". search.php : $response = array(); require_once __DIR__...
asked by 25.05.2015 / 21:15
2
answers

What is the name of the operator ... used in PHP 5.6?

From PHP 5.6 we now have the possibility to invoke or declare a function, stating that the arguments are infinite, using the ... operator. Example: function add(... $arguments) { return array_sum($arguments); } add(1, 2,...
asked by 16.09.2015 / 17:55
5
answers

Default Parameters

I'm having a problem with the parameters in a PHP function. For example: function exemplo($par1 = 1, $par2 = 2) { return $par1 . " - " . $par2; } exemplo(); // 1 - 2 exemplo(3); // 3 - 2 exemplo(3, 4); // 3 - 4 exempl...
asked by 24.04.2015 / 22:21
3
answers

Avoid the last occurrence of a concatenated character in a loop

The question is whether I have a foreach or any other repeat structure that receives data from the table and displays the categories: foreach ($categories as $c){ $c.nome . ' - '; } Assuming this code would display as a resu...
asked by 26.02.2015 / 01:27
2
answers

Error executing methods of a cascading class

I have the following code: 1. $customer = new Customer($apiContext); 2. $customer->setVat('XYZ0123456') 3. ->setName('Filipe') 4. ->setLanguageId(1); 5. (...) The following error occurs on line 3:    Call...
asked by 30.03.2015 / 12:37
5
answers

Get first name with Regular Expression

I need to get the first name with regular expression, but I'm not getting it right. Today I use the code like this: <?php preg_match('/[[:alnum:]]+/i', 'Alisson Acioli', $matches); return $matches[0]; ?>    Output: Alisson When t...
asked by 29.12.2015 / 18:36
2
answers

How to run a file with PHP?

I wanted to know some code in PHP that makes me open a file .exe , ie a line that makes execute a .exe file from the same server.     
asked by 02.12.2015 / 22:05