Hướng dẫn dùng commonmark trong PHP
Bài này gồm 3 phần chính: Show
Nội dung chính
I. PHP core1.1. Basic syntax1.1.1. Variables & Operatorsa. Array– Mảng là 1 trong những thứ linh hoạt nhất trong PHP. Khai báo mảng bằng từ khoá array(). b. Data types – Variables – Operatorsi. Data types – Kiểu dữ liệu 1.1.2. Control structuresa. Include & Require – Include và require dùng để ghép nối 2 file php riêng rẽ lại với nhau. b. use – Dùng để add tham chiếu thư viện, add tham chiếu file cần dùng. – Các cấu trúc điều khiển trong PHP tương tự như các ngôn ngữ lập trình khác, có cú pháp tương tự ngôn ngữ C, bao gồm: i. Cấu trúc vòng
lặp: ii. Cấu trúc điều kiện: 1.1.3. Functionsa. Common functions Là các hàm xây dựng sẵn của PHP được sử dụng nhiều. b. Functions // param2 is optional param with defaule value is ‘default’ ii. Global variable global $num; // use “global” to access var $num iii. Reference variable iv. Passing argument by reference $hoge = ‘test’; Thuật ngữ tiếng anh: 1.2. Object oriented programming– Tham khảo: http://code.tutsplus.com/tutorials/object-oriented-php-for-beginners–net-12762 1.2.1. Classes & Objectsa. Define a class private $_name; // Constructor // Destructor public function sayHello() b. Instantiate an object c. Inheritance // ClsB class inherits from the ClsA class // ClsC class inherits from the ClsA class $b = new ClsB(); $c = new ClsC(); 1.2.2. Namespace– Tham khảo: 1.3. Access to Database1.3.1. Choose API– PHP đưa ra 3 cách, tham khảo ở: http://php.net/mysqlinfo.api.choosing // mysqli // PDO // mysql 1.3.2. Using MySqli– http://codular.com/php-mysqli 1.3.3. Using PDO– http://codular.com/php-pdo-how-to II. Web development2.1. Handling request2.1.1. GET– Sử dụng
$_GET[param_name] để lấy giá trị tham của tham số truyền đi bởi phương thức GET Hello ! ==================================== Truy cập vào trang hello.php với đường dẫn: http://localhost/hello.php?name=Bop 2.1.2. POST– Sử dụng $_POST[param_name] để lấy giá trị tham của tham số truyền đi bởi phương thức POST ========================== =========form_action.php=========== Hi ! You are years old. ======================= ========== result =============== 2.2. Cookies / Sessions2.2.1. Cookies– Tham khảo: http://www.w3schools.com/php/php_cookies.asp 2.2.2. Session– Tham khảo: III. ExampleVcttai |