Questions tagged as 'php'

1
answer

Error connecting to SQL Server using CodeIgniter

I'm having an error connecting the database to my CodeIgniter project, I'm using SQL Server. $db['sql'] = array( 'dsn' => 'DRIVER={SQL Server}; SERVER=HOSTPT-01407; DATABASE=localidade;', 'hostname' => 'HOSTPT-01407', 'us...
asked by 06.10.2015 / 21:41
2
answers

php builder

I am trying to create a class with a constructor but it is returning me this error. I tried to do something similar to Java since I do not program in PHP yet, but it is returning this error:    Notice: Undefined variable: typegr...
asked by 20.02.2017 / 14:23
2
answers

How to send a POST request to a REST API in PHP?

I consider it quite simple to execute a GET request, I usually use: //$serverurl contem a url da api para a função desejada try { $cursos = file_get_contents($serverurl); } catch (Exception $e) { } After getting...
asked by 17.12.2013 / 15:22
3
answers

Insert character in specific position

How do I insert a character in a specific position? (In my case in the 4th character insert "."). Example: str = 30000000 gostaria que ela ficasse assim: 3000.0000     
asked by 07.05.2018 / 18:59
9
answers

Traverse an Array and check if any element is empty

Is there a native PHP function to loop through array and check if any element of this array is empty null ? Look at the code below: if(isset($_POST['btnCriaModelo'])){ $instArray = $_POST['idInstrucao']; $orderArray = $_P...
asked by 31.01.2014 / 08:47
3
answers

How to make a function where every time a variable is called is added plus 1? [closed]

For example, In the middle of my code I do echo $num; //me retorna 1, mas se eu ecoar novamente a variável "$num" //me retornará 2 e assim sucessivamente. I have tried in many ways, but I have not been able to: function...
asked by 25.08.2014 / 20:41
4
answers

How to invert words and count the total characters

As I do via php / html, for example, I have a input user to type anything, and the time that he clicks the "OK" button, I return the word he typed in reverse , and the amount of characters of the word that was typed by it? I know I'm g...
asked by 25.02.2016 / 19:31
2
answers

Adding data to a txt file

I have the following code: $msg = "teste"; $myfile = fopen("lista.txt", "w"); fwrite($myfile, $msg."\n"); fclose($myfile); If I change the value of the variable $msg it opens the file deletes the $msg previous and replaces it...
asked by 08.10.2018 / 21:34
4
answers

Return multiple arrays using a buffer without overloading memory

I'm developing an application where, in a report, I need to print something around 50,000 lines. When executing SELECT the error occurs:    Fatal error: Allowed memory size of 134217728 bytes exhausted (tried   to allocate 24 bytes) in   C: \...
asked by 27.02.2014 / 21:24
2
answers

Loop with "for" in a form with equal field sets

I have a data capture of a form where fields are 5 sets of equal fields. I want at the time of capturing for my array, I do not need to repeat: array[1] = post1, array[2] = post2 I know you can use a for : for ($i=1;$i<=5;$i++) {...
asked by 20.09.2014 / 01:24