Join David Powers for an in-depth discussion in this video What you should know before watching this course, part of Code Clinic: PHP.
What you need to know to get the most out of the PHP version of Code Clinic depends on who you are and why you're watching. Code Clinic has two main audiences. I expect most viewers will already use PHP and want to learn their skills. The other target audience consists of programmers, who use one or more other languages and who want to see how a particular problem is solved using PHP. If you already use PHP, I should warn you that the problems tackled in Code Clinic go way beyond the level of someone who's only just started learning.
You should already have a good understanding of PHP syntax and structures including arrays, functions, loops, and classes. I'll be using name spaces so the minimum version of PHP needs to be 5.3. Because PHP 5.3 is my baseline, I won't be using array or echo shorthand. Don't despair, if that list of requirements seems to exclude you. I've got a couple of beginner level courses here on lynda.com, introducing PHP and PHP for Web Designers.
My uploading files securely with PHP will bring you up to speed with classes and name spaces. If you're not a PHP developer, welcome aboard. Let me give you a quick overview of PHP. First of all, it's not a compiled language. The PHP script is written in plain text. And it's parsed by the zen engine on the web server. PHP's roots lie in making webpages interactive. So the code is often, but not always embedded in HTML.
PHP is not an object-oriented language, but it does have strong support for classes and objects. I'll be using a mixture of procedural and object-oriented code. Scripts and code blocks begin with an opening tag, which consists of an opening angle bracket and a question mark followed by PHP. The closing tag is a question mark followed by a closing angle bracket. When the file contains only PHP, the closing tag is optional.
Every statement must end with a semicolon. Leaving out the semicolon, is one of the most common causes of syntax errors. Strings can be enclosed in single or double quotes. Inside single quotes, variables are treated as literal texts. Inside double quotes, the value of the variable is used. For example, if the value of name is Dolly, using single quotes like this outputs, Hello, $name. Whereas using double quotes outputs Hello, Dolly.
The concatenation operator in PHP is a dot or period. Because it can be difficult to see on the screen, its often recommended to leave a space on either side. So is PHP a good or a bad language? On the negative side, it has many inconsistencies. Related functions often use inconsistent naming conventions. And expect arguments in a different order. For that reason, it's a good idea to have an editing program with good PHP code hinting.
Joseph Lowery has a short course on choosing a PHP editor in the lynda.com library. On the positive side, PHP's easy to learn. Its widely supported and there's an active community that will help. It also has a huge number of built in functions. Not only for manipulating strings and arrays but for handling calculations, communicating with a data base, working with a file system and even image processing. In spite of its shortcomings, I like PHP.
I hope you do too.
David introduces challenges and provides an overview of his solutions in PHP. Challenges include topics such as statistical analysis, searching directories for images, and accessing peripheral devices.
Visit other courses in the series to see how to solve the exact same challenges in languages like C#, C++, Java, Python, and Ruby.
Skill Level Intermediate
Q: I'm encountering script errors message with the prime_dates.php file used in the "Priming the date_record column" movie in this course. How can I resolve these errors?
A: To avoid script errors, use bindValue() instead of bindParam() in
Line 9 of the prime_dates.php file. You can also download the latest
copy of the exercise files, which corrects this issue for you. For a
more in-depth explanation of the difference between bindValue() and
bindParam(), check out the "Binding input and output values" video (http://www.lynda.com/PHP-
Q: Why can't I access the Lake Pend Orielle site (http://lpo.dt.navy.mil)?
A: The Lake Pend Orielle site is not accessible in some geographical areas. We have contacted the owner of the server to try to resolve this issue.
Q: I am unable to access the Lake Pend Oreille data from outside the U.S.
A: A static copy of this data is provided here for lynda.com members outside of the U.S