How to code your first php Web Page
PHP is one of the most popular programming languages for web development. It is offered nearly ubiquitously on shared hosting platforms. Many of the world’s leading content management systems, such as WordPress, Joomla, Drupal, Magento, Prestashop and lots of other most visited sites like Facebook, Wikipedia, Baidu, Yahoo!, Tumblr, Flickr, MailChimp, Fotolia, Digg, iStockPhoto and many more are written in PHP. Fortunately for developers, learning PHP is not exceptionally challenging. Like learning any skill it requires practice and patience. The first step is to understand what PHP is. Then the next step is to learn how to write a simple PHP web page.How to code your first PHP Web Page Click To Tweet
All PHP pages are executed on the server. When a user visits your PHP page with their web browser, the web server opens and reads your PHP script. It then prepares an output to send to the web browser. For this reason, PHP scripts typically include database calls and business logic calculations. These are typical aspects of your site that you want to hide from the general public. You don’t want anyone to be able to see your database structure, as that may give them ideas on how to hack it. These scripts also frequently handle form submissions as well. When you fill out a web form online, you may be sending that information to a PHP script for insertion into the user database.
PHP Usage Stats:
PHP is the scripting language of future. As reported by various aggregators and surveys like one by W3Techs PHP is one of the top most scripting language used worldwide. Moreover, its popularity and usage is increasing day by day with every new version.
In order to run PHP applications, you will need to have a web server that is configured to serve these types of pages. If you have a shared hosting environment, this will typically be included as part of your hosting package. If you have cloud hosting, you may need to install both Apache and PHP to see your pages. Windows users can install a software package called XAMPP to get a both a PHP web server and database on their local computer. Similarly, Mac OS X users can install MAMP which includes a PHP server and database. These are free and simple methods of installing an environment to run and test your PHP pages.
BEST DRAG AND DROP WEB DESIGN TOOL
Syntax of PHP:
The syntax of PHP is relatively simple. Code your web page as you normally would, but all PHP code must be enclosed in “<?php” and “?>”. The following program outputs “Hello World” into your web browser.
<html> <body> <?php echo "Hello World"; ?> </body> </html>
Save the above code to a file called example1.php and upload it to your web server. Then visit that page in your web browser. You will see “Hello World” on your screen.
PHP contains far more exciting features than just outputting static text. Variables store values within a PHP script, and they are defined with dollar signs in front of them. Therefore, “$number” can hold a value such as 1 or -10. The following code adds four and five. The result is displayed to the user.
<?php $num1 = 4; $num2 = 5; $result = $num1 + $num2; ?> <html> <body> <?php echo $result; ?> </body> </html>
Functions are a way of defining common routines or calculations so that the same code doesn’t need to be written in multiple locations. Each function has input parameters and a returned value. The following code defines a function that takes two numbers as input parameters and returns the sum of them.
<?php function add($num1, $num2) return $num1 + $num2; ?>
The following code uses the function above to display the results of four plus five and six plus seven.
<?php $result1 = add(4, 5); $result2 = add(6, 7); ?> <html> <body> The results are: <?php echo $result1; ?> and <?php echo $result2; ?>. </body> </html>
PHP is a very versatile and advanced scripting language that is capable of handling from basic php web pages to advanced web applications. Database-driven web pages, user authentication, and shopping carts can easily be coded through PHP. It is also a highly marketable job skill as many companies rely on full-time PHP developers to power their web infrastructure. Learning PHP enables you to build powerful websites for any idea!
If you don’t want to learn PHP: If you want to start your career as a Web Designer or need to have your own website but don’t want to learn PHP and HTML/CSS just download TemplateToaster. It is a web design software for designing stunning WordPress, Joomla, Drupal, Magento, Prestashop and Blogger Themes. I hope you enjoyed this article, let me know your thoughts through comments.