Join David Powers for an in-depth discussion in this video What you should know before watching this course, part of Code Clinic: PHP.
- View Offline
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.