VARIS VONGUEA-AREE

PHP 🐍 Python 🔥 Golang 🇹🇭 Bangkok Thailand

High level experience in web design and development knowledge, producing quality work.

For more info
  • Home
  • About
  • Project
  • Blog
    • th
  • Varisz
  • PHP
  • พื้นฐาน PHP

พื้นฐาน PHP

เป็นภาษา server side language

#php --ini     // PHP Cli in Command
#php -m

php_info();   //Check Information PHP

Composer

package manger ของภาษา php ใช้ในการ manage dependencies

Escape Sequence

\n   //New Line
\"   //Double quote
\r   //Carriage Return
\t   //Tab
\\   //Blackslash
\$   //Dollar sign

Objects

ob_start();      //Turn on output buffering
ob_get_contents();  //Return the contents of the output buffer
ob_end_clean()  // Clean output buffer and turn off output buffering
ob_end_flush() // Flush(send)output buffer,turn off output buffering

Explode แยกข้อความ

$url_request = explode ("/",$_SERVER['REQUEST_URI']);//แยก string เป็น array ด้วย '/'
print $url_request[1];

Regular Expression

$url = "https://example.org/path/here";$matches = [];
$regex = "@^(http(s?))://(.*)$@i";
if (preg_match($regex, $url, $matches)) {
var_dump($matches);
}

Decode

rawurldecode

echo rawurldecode('foo%20bar%40baz'); // foo bar@baz

Url Decode

$value = "%e0%b8%a3%e0%b8%b5%e0%b8%a7%e0%b8%b4%e0%b8%a7%e0%b8%a5%e0%b8%b9%e0%b8%81%e0%b8%84%e0%b9%89%e0%b8%b2-%e0%b9%82%e0%b8%8a%e0%b9%8a%e0%b8%84%e0%b8%ad%e0%b8%b1%e0%b8%9e";
$normal = urldecode($value);
$normal_ex = explode('-',$normal);

Error Handling

catch

  • Exception $e
  • LogicException $e
  • RuntimeException $e
try
{
$div = invert(0);
}
catch (LogicException $e) {}

https://apzentral.github.io/php-the-right-way/
https://secure.phabricator.com/book/phabflavor/article/php_pitfalls/
http://www.expertphp.in/category/php?page=2

https://phptherightway.com/pages/Design-Patterns.html

Related

Python Request
Django Rest Framework
PM2 (Production Process Manager)
Extention ที่ต้องมี Visual Studio Code

© 2021 All rights reserved by varisz