Head First PHP & MySQL by Lynn Beighley
My rating: 4 of 5 stars
At OptimWise, I build websites with WordPress, and currently focus on front-end development (HTML and CSS). I’ve tweaked PHP, but I want to get better at modifying WordPress themes and plugins, which requires working with PHP and MySQL. This book was very helpful, as it includes step-by-step examples of building simple web applications with PHP and MySQL, and covers database fundamentals. The book is visual and easy to understand, explaining concepts and providing practical application. Like other Head First books, it’s full of quirky pictures and cartoons.
while
loop: repeat code while a condition is met.for each
loop: loop through an array one element at a time, without using a test condition.for
loop: loop based on a specific number of iterations, using a counter and test condition.trim()
and mysqli_real_escape_string() to prevent SQL injection.explode()
breaks a string apart into an array of substrings.implode()
builds a string out of an array of strings.str_replace()
replaces text in a string.substr()
extracts part of a string.preg_match()
checks if a string matches a regular expression.preg_replace()
replaces a substring based on a regular expression.strip_tags()
removes HTML tags from a string.&&
(and
) and II
(or
), because those operators are short-circuited whenever possible; if the first operand can determine the expression’s outcome, the second operand is ignored.isset()
checks if a variable exists.empty()
checks if a variable has contents.require_once()
results in an error if an include file is missing, and it prevents files from being included more than once. include
doesn’t do these.@
in front of any PHP function to suppress error reporting.text expression ? statement 1 : statement 2
.rand()
returns a random integer.simplexml_load_file()
loads an XML file from a URL and makes the data accessible through an object.mysqli_error()
outputs error messages.AS
to establish an alias.LIMIT
to limit the number of rows returned by a query.