Tag: ide
PHP:server-side scripting language
by sanchitgulati on Oct.02, 2009, under Open Source, php
PHP, stands for PHP: Hypertext Preprocessor, is a widely used, general-purpose scripting language that was originally designed for web development, to produce dynamic web pages. It can be embedded into HTML and generally runs on a web server, which needs to be configured to process PHP code and create web
page content from it.You can read more from wiki.
To learn php,you would require to install Apache, MySQL, PHP on your local machine.
If using Windows : Install AppServ or Wamp . ( Appsevr for no0bs)- ( Latest Stable release for AppServ 2.5.10)
If using Linux : Install lamp ( Linux Apache Mysql Php )
Further Tutorial are guided according to Appsevr installation.
Step 1.
Tutorial on this link is self explaining.
Step 2.
Checking the installation:
Open firefox or any other broswer and typie localhost in address bar ( this is the space where you type facebook.com )
If you see the html page with “The AppServ Open Project – 2.5.10 for Windows”,then congrats.
Open “http://localhost/phpinfo.php” to know more about php-server installed.
Step 3.
Appsevr store all public html files “C:\AppServ\www\” – Default Location
Step 4.
Create a new file in the above folder with extension php , example hello.php ( Not hello.php.txt)
Edit the file using Notepad and type in the following code
<html>
<body>
<?php
echo “Hello World”;
?>
</body>
</html>
Step 5.
In your broswer open “localhost/hello.php”
You should be seeing a html page with “Hello World”.
Basic PHP Syntax
A PHP scripting block always starts with <?php and ends with ?>. A PHP scripting block can be placed anywhere in the html document,as you can see in example above.
OUTPUT
`echo` is used for printing strings or variable,similar to printf() or cout in c/c++ .
Also,
echo (“Hello World”);
printf(“Hello World”);
INPUT
As php is server-side scripting language it doesn’t not take inputs like c/c++ but accepts arguments in the form of GET or POST .Which is out of the scope of this tutorial. #WaitForOurWorkshop
VARIABLE
All variables in PHP start with a $ sign symbol and carries no datatype,So we don’t need separate variable for int,float or char.
<?php
$strg = “Hello World”;
echo (“$strg”);
$x=16;
echo $x;
?>
FURTHER LESSONS
Operators,If…Else,Switch,Arrays,While Loops,For Loops,Functions are similar to c/c++ you can learn about them on http://www.w3schools.com/PHP/
IDE (Integrated development Enviroment)
There are many open source as well as proprietary software available for easy development of php scripts.Notepad++ or PHPeclipse (Plug-in to Eclipse) works great on windows or you can spend thousands for Adobe Dreamweaver, which is the best option available to industry as of now.For linux machine try gPHPEdit or Codeblocks
LINUX INSTALLATION
Blog on how to install and configure LAMP on linux machine will follow shortly.Atleast I hope so.
DOUBTS AND QUERY
You can ask any doubt on php or any other open source technology on http://cuclante.com/forum/