Please enable JavaScript.
Coggle requires JavaScript to display documents.
Chapter 7_php (Breif (vs. JavaScript (PHP processor (modes (Copy mode:,…
Chapter 7_php
Breif
-
-
-
-
-
executed on the server, result is returned HTML (!DOCTYPE html)
-
what can PHP do?
-
•can create, open, read, write, and close files on the server
-
-
•can add, delete, modify data in your database
-
-
variable
variable name
can contain letters, digits, underscore
-
-
-
-
-
-
-
reserved words
-
and, else, break, list, etc.
-
empty(function)
false if the variable exists and has a non-empty, non-zero value otherwise returns true
arithmetic operators
-
-
-
-
-
Arithmetic functions
floor, ceil, round, abs, min, max, rand, etc.
-
FILE I/O
-
File tests:
-
file_exists,is_dir,is_file, is_readable,is_writable,is_executable, filesize(in bytes)
File status:
-
•fileatime(last access time of file),
•filectime(inode change time of file),
-
•filemtime(file modification time),
-
•fileperms(file permissions),
-
-
-
File I/O:
-
-
-
-
fwrite(file,string) (writes to handle)
fread(file, length) (reads from handle)
-
-
-
I/O work not only with file names, but also URLs to access remote files.
Directory handling
-
-
-
•opendir(opensdir,returns handle)
-
-
-
output statements
print
takes a string, but will coerce other values to strings
-
-
-
Returns 1, so can be used in an expression
printf
printf("The price of %4s is %4d", $item, $price);
echo
-
-
Syntax: () when used with one string, comma when used with many strings
-
-
-
-
-
-
-
-
scalar type conversion
implicit
-
-
String to numeric
contains E, e, period(.) convert to double
-
not begin with a sign or gigit, zero is used
-
explicit
-
-
-
settype($total, "integer")
-
-
form handling
GET
-
can't be used to send binary data, like images or word documents
-
-
-
-
-
-
-
-
-
-