Server-Side PHP: Part 1: Server Output

Server-Side PHP

PHP is a programming language frequently used for server-side web development.


Server Output

When used in a server setting, PHP can be invoked as part of its short tag system. The opening tag, <?php, and closing tag, ?>, mark content as PHP code.

Any function that would use the default output are routed to server output. This means that functions like echo and print send their output to the server. These can easily be used to display different content.

Multiple Short Tags

As part of the short tag system, PHP files are preprocessed prior to the output being sent to clients. Multiple uses of PHP short tags, then, can be used within a HTML file to compute different content.

These can appear before, within, or even after HTML content. Because they are processed first, they will be removed from any final client output.

PHP in HTML or using PHP to output HTML?

Depending on the scale of a project, the difference between having PHP in HTML or using PHP to generate HTML may not matter. However, being aware of both options can help in understanding how they may help or hinder development.

Generally, it is a good idea to separate functionality according to purpose. Server computation should not take place within HTML files and should be within their own packages or modules. Calling functions or using include to invoke certain classes can help in organizing projects through having the final result appear in a HTML file.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.