Saturday 14 September 2013

Writing your first "Hello World" script | Chapter 1 Cont.



Firstly create a file with any random name with an .php extension & save it in the web root directory.

introduction to phpintroduction to php












 A PHP block started <?php tag & ends with ?>. There are two basic statements for showing an simple Hello World! message on the browser.

Using Print -

<?php 
 print "Hello World!";
?>

Using Echo -

<?php
echo "Hello World!";
?>


Write & save the above php code. When you run the file on your browser, it will show the expected result which is Hello World!.

introduction to php












One main thing to know before you move further is that HTML can be embedded inside php & php can be embedded inside html.


  • Using PHP inside HTML

<html>
<head>
<title>TEST</title>
</head>
<body>
<?php echo "PHP-Sec"; ?>
</body>
</html>



php hello world scriptintroduction to php



But the interesting part is when you look at the page source code, you will not find any php code but instead HTML source code. As we have read in the previous introduction chapter that php is an server side scripting language. The code is executed on the server side & the output is converted & shown as HTML on the client side. No one can view the original source code.




  • Using HTML inside PHP

<?php
echo "<html>";
echo "<head>";
echo "<title>TEST</title>";
echo "</head>";
echo "<body>";
echo "<h1>PHP-Sec</h1>";
echo "</body>";
echo "</html>";
?>


introduction to php




Now let's have get forward to the next step which is Comment Line. Comment line is used to comment out something which is ignored while the script gets executed. It doesn't effect the PHP code. The basic purpose of using comment line are
-  Writing Code Description
-  Algorithm Working
- Writing credits
and so on.

Tuesday 10 September 2013

Introduction to PHP | Chapter 1

Welcome to the very first tutorial of PHP. In this chapter i will be giving an brief introduction to php language.


  • What is PHP?
- It was originally developed by  Rasmus Lerdorf in the year 1994.

- PHP is a server side scripting language just like ASP & unlike c, java etc. The script is executed on the server side & is shown as HTML on the client side thereby hiding the original source code.

php-sec










- PHP is a loosely typed language as we don't need to specify a data type while creating a  variable like c#, c etc. We just create a variable & assign it integer value.
- PHP is an Compiled language after PHP4.
- It is an Open source software which supports various Platforms like Windows, Unix, mac etc.3
- PHP/Apache is pre-installed in OS X.
- It Supports various databases like  MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.

php-sec