Difference between revisions of "PHP"

From wiki
Jump to: navigation, search
(Created page with "Category:Programming Script language for dynamic web-pages. The syntax and concepts used are similar to Perl ;$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbnam...")
 
Line 10: Line 10:
 
;$row    = mysqli_fetch_array($result, MYSQLI_NUM);
 
;$row    = mysqli_fetch_array($result, MYSQLI_NUM);
 
:Fetch a row as array
 
:Fetch a row as array
 +
 +
==Functions==
 +
 +
Function have global scope, you do not need to declare them before calling
 +
 +
<syntaxhighlight lang=php>
 +
 +
<?php
 +
function func1($arg1, $arg2)
 +
{
 +
    <codeblock>
 +
    return $value;
 +
}
 +
?>
 +
</syntaxhighlight>
 +
  
 
=Install=
 
=Install=

Revision as of 16:27, 9 June 2019

Script language for dynamic web-pages. The syntax and concepts used are similar to Perl

$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname, $dbport) or die ('Error connecting to mysql');
Open database connection
$result = mysqli_query($conn,$query) or die('Error, retrieve failed');
Execute a query on the opened connection
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
Fetch a row as hash
$row = mysqli_fetch_array($result, MYSQLI_NUM);
Fetch a row as array

Functions

Function have global scope, you do not need to declare them before calling

<?php
function func1($arg1, $arg2)
{
    <codeblock>
    return $value;
}
?>


Install

On debian (and its derivates)

apt-get install php-fpm php-mysql
Install php7 and mysql support
Fix php security by editing /etc/php/7.0/fpm/php.ini
Uncomment line with cgi.fix_pathinfo and set it to 0