1. GET NETWORK parameter
$_POST, $_GET, $REQUESTcontent:
exampel: $_GET['name']
ref: 1 2 3
2. isset()
Content: check variable is setex: isset($_GET['action'])
3. print_r($array, true)
parameter: true, meaning not output to stdoutcontent: output $array content
ex: error_log(print_r($array, true))
ref: 1
4. htmlentities
content: change special word to the htmlspecail word<?php
$str = "A 'quote' is <b>bold</b>";
// Outputs: A 'quote' is <b>bold</b>
echo htmlentities($str);
// Outputs: A 'quote' is <b>bold</b>
echo htmlentities($str, ENT_QUOTES);
?>
ref 1
5. pcntl_fork
ref 1 2 3 4 5
6. Reflect class
----class ClassOne
{
protected $arg1;
protected $arg2;
//Contructor
public function __construct($arg1, $arg2)
{
$this->arg1 = $arg1;
$this->arg2 = $arg2;
}
public function echoArgOne()
{
echo $this->arg1;
}
}
$str = "One";
$className = "Class".$str;
$class = new \ReflectionClass($className);
$instance = $class->newInstanceArgs(array("Banana", "Apple"));
$instance->echoArgOne();
---------
7. Array Function pass by
<?php
//Enter your code here, enjoy!
$array = array("1" => "PHP code tester Sandbox Online",
"foo" => "bar", 5 , 5 => 89009,
"case" => "Random Stuff: " . rand(100,999),
"PHP Version" => phpversion()
);
assignEmpty($array, "ipo");
function assignEmpty($array, $field)
{
$array[$field] = 100;
}
$array["ipb"] = 77;
print_r($array);
8. PHP Redirect
if (/*Condition to redirect*/){
//You need to redirect
header("Location: http://www.yourwebsite.com/user.php"); /* Redirect browser */
exit();
}
else{
// do some
}
9. PHP html add the code
in .htaccess
AddType application/x-httpd-php .html .htm
ref 1
9 PHP auth
https://www.php.net/manual/en/features.http-auth.php
ref
http://ms7.fhsh.tp.edu.tw/php5c/features.http-auth.html
10. php varaible request
https://stackoverflow.com/questions/520132/does-static-variables-in-php-persist-across-the-requests
https://softwareengineering.stackexchange.com/questions/276512/is-this-a-race-condition
10 PHP stdclass and array change
$query = new stdClass();$query->age = 10;
$query->name = "andy";
echo $query->{"age"};
echo $query->{"name"};
/////////////////////////
$qArray = (array) $query;
echo $qArray{"age"};
echo $qArray{"name"};
沒有留言:
張貼留言