Please enable JavaScript.
Coggle requires JavaScript to display documents.
PHP (Practical (Request Response (Encoding (GET: urlencode, rawurlencode,…
PHP
Practical
PHP Fundamentals
Basics
Comment:
// for single line
/**/ for multi line
Naming: use _ instead of camelCase
Casting:
gettype, settype, (integer)
Variable: $
Embed page: <?php ?>
Function: function test() { }
Output:
echo, print, print_r
Constant: define
Built-in functions
Int function:
abs, pow, sqrt, fmod, rand
Float function:
round, ceil, floor
Validate function:
is_int, is_float, is_numeric, is_bool, is_null, isset, empty
Array function:
count, max, min
sort, rsort
implode, explode
in_array, array_key_exists
String function:
strtolower, strtoupper, ucfirst, ucwords
strlen, trim, strstr, str_replace
str_repeat, substr, strpos, strchr
Logical operators
If-else
Ternary
Switch-case
Loops
For loops
Foreach
While loops
Continue
Break
Request Response
Encoding
GET:
urlencode, rawurlencode
HTML:
htmlspecialchars, htmlentities
Files:
include, require, include_once
Headers:
header, header_list
Cookies:
setcookie
Get data from user:
$_GET, $_POST, $_COOKIE, $SESSION
Debugging:
var_dump, debug_backtrace, get_defined_vars
mysqli
Open connection: mysqli_connect
Check connection: mysqli_connect_errno & mysqli_connect_error
Close connection: mysqli_close
Perform query: mysqli_query
Use returned data: mysqli_fetch_row, mysqli_fetch_assoc, mysqli_fetch_array
Release returned data: mysqli_free_result
Theory
Architecture
Request-response cycle
Request page from Apache on based on IP address
User enter URL on browser
If contains PHP, process PHP
If PHP contains SQL, execute SQL
Respond and display page in HTML
Browser will look on IP address based on URL
Concepts
Associative array
Key-value pairs
Storing user data
Cookie
Session