Learn PHP
PHP is a general-purpose widely-used server-side scripting language originally designed for web development to produce dynamic web pages. It is among one of the first developed server-side scripting languages that is embedded into a HTML source document, rather than calling an external file to process data.PHP was originally created by Rasmus Lerdorf in 1995.What Is PHP?
PHP stands for Hypertext Preprocessor. While other languages, like Javascript, function on the client-side, your PHP code will execute on the server level. It works seamlessly with our HTML. Furthermore, your PHP can be embedded within your HTML and vice versa. The important thing to remember is that, no matter how complicated your PHP is, it will ultimately be output as simple HTML.Why Would I Use PHP?
HTML is 100% static. By implementing PHP into your code, we can create dynamic sites that will change dependent upon specified conditions. With a community base second to none, this open-source language has proven itself over the years to be one of the best options for dynamic web applications.Is PHP Similar To Any Other Languages?
Absolutely. If you have even a modest amount of knowledge when it comes to ASP.NET, Perl, Javascript, or C#, you’ll find that you pick up the syntax quickly.What Do I Need To Get Started?
You must have the following installed on your computer in order to begin.- Apache
- MySQL
- Web Browser
- Text Editor
- PHP
WAMP, MAMP
There is few acronyms to learn. “WAMP” stands for “Windows-Apache-MySQL-PHP”. It is an open source project that will allow us to download everything that we need to get started right away. If you’re a Windows user, visit WampServer.com. On the other hand, if you’re using a Mac (MAMP), you’ll want to pay a visit to Mamp.infoThe Basics
In order to alert the server that we are working with PHP, you’ll need to use the following syntax when adding PHP into your HTML documents:<?php ...code goes here ?> |
<?php echo "This is PHP in action" ; ?> |
Defining Variables
We can assign values to variables quite easily. Rather than using “var” (C# and Javascript), or “dim” (VB), we can declare a variable in PHP by using the “$” symbol. For instance, let’s say that I want to assign the previous string to a variable called “myVariable”. I would write…<?php $myVariable = "This is PHP in action" ;
echo $myVariable ; ?> |
Inserting Comments Into Your Code
If you’re familiar with CSS and Javascript, you’ll find that inserting comments in PHP is virtually the same.<?php # This is a single line comment. //
This is the most common way of commenting out your code. /* Here is a way to comment over multiple lines. This is the exact same way that you would comment in */ ?> |
Combining HTML With Our PHP
As said previously, remember that PHP and HTML can work in combination. Simply because we’re in the middle of a PHP statement does not mean that we can’t embed elements such as a break or strong tag.<?php echo "<strong>This text is bold.</strong>" ; ?> |
Defining Your First Function()
Creating functions in PHP is nearly identical to Javascript’s implementation. The basic syntax is…<?php function name ( $arguments ){ your statement goes here; } ?> |
<?php function addNumbers (){ echo 10 + 5; } addNumbers(); ?> |
<?php
function addNumbers($firstNumber, $secondNumber){
echo $firstNumber + $secondNumber;
}
addNumbers(10, 5);
?>
If these concepts are still vague, go back and read the article oncemore. Also, be sure to check out the following resources which will help you to further grasp the syntax of PHP. Please feel free to ask questions or offer advice in the comment section. I’ll be sure to work your thoughts into second step
Required Resources
-
Lynda.com : PHP With MySQL Essential Training
Website and database assimilation is a necessity for many of today’s businesses, and learning to work with PHP is key to integration success. The objective of PHP with MySQL Essential Training is to teach both new and experienced web developers the comprehensive steps for building dynamic, data-driven, interactive websites.
Visit Article
-
PHP 101 : Down The Rabbit Hole
To put together a cutting-edge Web site, chock full of all the latest bells and whistles, there’s only one acronym you really need to know: PHP.
Visit Article
-
PHPBuddy.com : Your First PHP Code
This site covers the basic PHP syntax, including variable usage.
Visit Article
-
PHP.NET : A Simple Tutorial
Here we would like to show the very basics of PHP in a short, simple tutorial.
Visit Article
-
W3Schools.com : PHP Tutorial
This site will give you as detailed an introduction to PHP as you could ever hope for. Be sure to spend at least an hour or so here.
No comments:
Post a Comment