apt install php-fpm php7.4-sqlite3 php7.4-mbstring
php -m <- check module
# ln -s /opt/remi/php56/root/usr/lib64/php/modules/sqlite3.so /usr/lib64/php/modules/sqlite3.so
Configuration | Note |
---|---|
expose_php = Off | Don't display php version |
Configuration | Note |
---|---|
upload_max_filesize = 20M | |
max_execution_time = 30 | Max execution tie for each script in seconds. |
memory_limit = 128M | Max amount of memory a script may use. |
Librarie | Note |
---|---|
PEAR | http://pear.php.net/ |
GeSHi | http://qbnz.com/highlighter/ |
Framework | Note |
---|---|
CodeIgniter | http://www.codeigniter.com/ |
FuelPHP | http://fuelphp.com/ |
CakePHP | http://cakephp.org/ |
Laravel | http://laravel.com/ |
<?php print "Hello World!"; echo "Hello World!";
<?php $array = array(1,2,3); var_dump($array); array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) }
// aaaaa # aaaaa
/* aaaaaaa bbbbbbb */
$a . $b
$a + $b $a - $b $a * $b $a / $b $a % $b
$a == $b $a === $b $a != $b $a <> $b $a !== $b $a < $b $a > $b $a <= $b $a >= $b
$a and $b $a && $b $a or $b $a || $b !$a //$a is false $a xor $b
$a = 'string'; $i = 1;
<?php $int = 100; $float = 100.123;
<?php $i = 1 + 1; $i = 1 - 1; $i = 1 * 1; $i = 1 / 2;
<?php $div = intval(3 / 2); $mod = 3 % 2;
<?php $i++; $i--;
<?php $str1 = "abc\tcde"; // abc cde $str2 = 'abc\tcde'; // abc\tcde $str3 = "$str1 100" // abc cde 100 $str4 = "{$str1}100"
<?php $join1 = 'aaa' . 'bbb'; $join2 = implode(',', array('aaa', 'bbb', 'ccc')); $split = explode(',', 'aaa,bbb,ccc'); $length = strlen('abcdef'); // mb_internal_encoding('UTF-8'); $mb_length = mb_strlen('aiueo'); $substr = substr('abcd', 0, 2); // ab // search $index = strpos('abcd', 'bc');
$_SERVER['REMOTE_ADDR']
<?php //test.php?id=10&group=test echo $_GET['id']; echo $_GET['group'];
<?php /* <form method="POST" action="test.php"> <input type="text" name="key" value="ABC"> <input type="text" name="page" value="3"> <input type="submit" value="OK"> </form> */ echo $_POST['key'];
<?php $array1 = array(1, 2, 3);/ $array2 = array('a' => 1, 'b' => 2, 'c' => 3); $array3 = array(1, 'a' => 1, 2);
<?php $i = $array1[0]; $s = $array2['a'];
<?php $array1[3] = 1; $array2['z'] = 'zzz';
Example | Name | Result |
---|---|---|
a == b | Equal | true if $a is equal to $b |
a === b | Identical | true if $a is equal to $b, and they are of the same type. |
a != b | Not equal | true if $a is not equal to $b |
a <> b | Not equal | true if $a is not equal to $b |
a !== b | Not identical | true if $a is not equal to $b, or they are not of the same type. |
a > b | Greater than | true if $a is strictly greater than $b. |
a >= b | Greater than or equal to | true if $a is greater than or equal to $b. |
a < b | Less than | true if $a is strictly less than $b. |
a <= b | Less than or equal to | true if $a is less than or equal to $b. |
<?php if ($var == xxxx) { }
if ($sample > 5) { }
<?php if (condition): ?> <span>hoge</span> <?php endif; ?>
<?php if (!empty($value)) { } else { }
<?php if (condition): ?> <span>hoge</span> <?php else: ?> <span>foo</span> <?php endif; ?>
<?php if (condition) { } else if { }
<?php if (condition): ?> <span>hoge</span> <?php elseif (condition): ?> <span>foo</span> <?php endif; ?>
if($cond===true){ func1(); }else{ func2(); } $cond===true ? func1() : func2();
<?php $i = 0; while ($i < 5) { // $i++; }
<?php while ($i < 5): ?> <span><?php echo htmlspecialchars($i); ?></span> <?php $i++; ?> <?php endwhile; ?>
<?php for ($i = 0 ; $i < 5 ;$i++) { }
<?php for ($i = 0 ; $i < 5 ; $i++): ?> <span><?php echo htmlspecialchars($i); ?></span> <?php endfor; ?>
<?php foreach ($array as $v) { // $v : value } foreach ($array as $k => $v) { // $k : Key 、$v : value }
<?php foreach ($array as $v): ?> <span><?php echo htmlspecialchars($v); ?></span> <?php endforeach; ?>
<?php $day = "Sun"; switch ($day) { case "Sun": echo "Sunday\n"; break; case "Mon": echo "Monday\n"; break; case "Tue": echo "Tuesday\n"; break; default: echo "Unknown\n"; break; }
<?php require 'sample.php';
<?php require_once 'sample.php';
<?php include 'common.php';
<?php include_once 'sample.php';
<?php function sum($v1, $v2) { return $v1 + $v2; } $total = sum(1, 2); // $total = 3 function get_multi($v1, $v2) { $v1 += 100; $v2 += 200; return array($v1, $v2); } list($ret1, $ret2) = get_multi(1, 2); // $ret1 = 101 / $ret2 = 202
<?php // Read $fp = fopen("/path/to/file", "r"); if (!is_resource($fp)) { die("can't open file"); } while (!feof($fp)) { $line = fgets($fp, 4096); // } fclose($fp); // Write $fp = fopen("/path/to/file", "w"); if (!is_resource($fp)) { die("can't open file"); } fputs($fp, $buff); fclose($fp);
<?php $list = file("/path/to/file");
<?php // read $contents = file_get_contents("/path/to/file"); // write file_put_contents("/path/to/file", $buff);
if (empty($host)) { $ErrFlg = 1; $ERRMSG = $ERRMSG . "Your host or IP is empty.<br>"; }
if (!preg_match("/^[a-zA-Z]+$/", $record)) { $ErrFlg = 1; }
if(!preg_match("/^[0-9]+$/",$num)){ $ErrFlg = 1; }
if (mb_strlen($host) > 10) { $ErrFlg = 1; $ERRMSG = $ERRMSG . "Your number of character is too wordy.<br>"; }
<?php $IP = "123.45.67.89"; if(preg_match('/^(([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/', $IP)){ echo("$IP is IP address."); }else{ echo("$IP is not IP address."); }
if(!preg_match('/^([A-Za-z0-9][A-Za-z0-9\-]{1,61}[A-Za-z0-9]\.)+[A-Za-z]+$/', $host)){ $ErrFlg = 1; $ERRMSG = $ERRMSG . "Your FQDN is bad.<br>"; }
if (!preg_match('/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)$/' , $mail)) { $ErrFla = 1; }