PHP
Setting up a proper PHP.INI file can be rather burdensome. This list will point out some of the most popular (and important) settings within your PHP.INI.
I purposely left out the "register_globals" and "safe_mode" setting for a couple of reasons:
A variable is best described as a container for stored information. The information can be anything from a number, a string of text or an array. Variables are extremely flexible in what kinds of data it will store and you can do an assortment of operations with them. You can send the data stored in a variable to the web browser, save it to a database or even email its contents to someone.
Any good programmer will tell you that adding comments to your code can be extremely useful. Since you are on your way to becoming a PHP programmer, it is wise to heed the advice of other programmers.
Comments in your code do nothing to the script itself. Their main purpose is to help you understand why you did something. PHP supports three methods of adding comments to your code: #, // and /* */.
If you are familiar with HTML, you know that creating easily readable HTML files makes the process of debugging and reading your source files much easier. This is where whitespace comes in. Whitespace is all the blank spaces and lines that are not visible, but spaces out your text., Using the spacebar, TAB key, the Enter/Return key, etc... helps you space out your text so it is not bunched up in one line or a continuous string of text with no breaks.
So we are now up and running. Now we can start getting into the actual coding. This guide page will walk you through some of the methods for sending text, via PHP, to the web browser. You may be wondering why you would want to send text to the browser using PHP when you can just type it in (X)HTML? Easy, (X) HTML isn't dynamic. By using PHP to output text to the screen you are allowing for multiple strings of text to potentially be seen by the user.
Now that you have installed all the required software (or your using a web host), we need to test your environment to see if it can actually run PHP code. We do this by creating a test file, add some code and navigate to that file via a web browser.
First thing we have to do is create a file named index.php. Once that is done add the following code:
Now that you have installed all the software needed as well as followed their instuctions on configuring it correctly, we can begin with the ubiquitous "Hello World" PHP example.
Open a text editor and copy and paste the below starter text into it:
In order for you to create PHP scripts, you will require a few pieces of software:
This guide, in the later chapters will be talking about databases, so in order to follow, you will want to download MySQL.
Since PHP is a server-side language, all code is stored on the web (or file) server and when a user accesses the web page, PHP will interpret it and send it to the users web browser.
A typical setup would be:
So you would like to learn PHP, the popular scripting language used to run countless websites?
What Is PHP?
When PHP first came out it originally stood for Personal Home Page. Over 10 years ago, 1994 to be exact, a man named Ramus Lerdorf created PHP to track visitors who viewed his online resume. As time progressed and PHP's features were expanded on, it got a new name: PHP: Hypertext Preprocessor.