O'Reilly logo

PHP: The Good Parts by Peter MacIntyre

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. Casing the Joint

Now that you know the very basics of a PHP file, how to run it through a web server, and how to display some content in a web browser, let’s look more closely at the language’s building blocks and how you can use them to construct larger, more complex websites and web applications. I call this process casing the joint because it involves taking a basic cursory look at the PHP environment to get a better handle on the basics of a PHP code file. The mastery of the building blocks you will be exposed to in this chapter will stand you in good stead, so be sure that you have a strong understanding of them and that you know how and when to use them. Initially, we will look at small segments of a PHP code file (like variables and types of data), and then we will discuss how to control the outcome of a request with the use of decision-making code, also known as flow control. Finally, we will explore some concepts that explain the overall environment of a PHP application: where items are placed in memory (server versus client) and how to retrieve information from those areas.

Whitespace, Comments, and Basic Syntax

As far as PHP is concerned, whitespace is ignored when code is sent to the interpreter. This means that all comments and blank lines are effectively stripped out of the code file as it is running.

Note

If you’re trying to achieve microoptimization and want to send some really clean code to the interpreter so that it doesn’t have to take time to strip out ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required