Difference between revisions of "/Hello World/"
From Script | Spoken-Tutorial
(Created page with ''''Title of script''': Hello World '''Author: Anurag Jain, Abhishek Kumar Srivastava''' '''Keywords: localhost, client-server''' {| style="border-spacing:0;" | style="border-…') |
(No difference)
|
Latest revision as of 15:18, 26 December 2012
Title of script: Hello World
Author: Anurag Jain, Abhishek Kumar Srivastava
Keywords: localhost, client-server
|
|
|
Hello, Welcome to the spoken tutorial for PHP and MySQL. In this tutorial we'll show you how to write basic PHP program and execute over Apache server. Moreover you'll learn how to embed PHP script in HTML, how to print a string and concatenate two different strings in PHP. So basically with this tutorial, we will work, for the first time, on PHP platform and give a start-up to our programming. |
|
As we'll be working on windows platform, before we start writing our codes, we need to check certain things.
1: We'll be using XAMPP version 1.7.3 or later which have PHP 5.3.1, MySQL 5.1 and Apache 2.2. It is advised to use latest version of XAMPP only. 2: Click XAMPP icon from your task bar or start menu. 3: Open XAMPP control panel running in your task bar and start Apache service. 4: Open notepad++(text editor). We'll use it as our editor throughout the tutorial ; |
|
Basically PHP codes are embedded between HTML tags as per the need. It provides the flexibility and freedom to the user to display dynamic content in an organized manner.So let's start by writing a basic and conventional “Hello world” program which will print the string “Hello World”. |
|
<html> <head> <title>Hello World</title> </head> <body> <?php //opening PHP echo "Hello World"; //prints string //closing PHP ?> </body> </html> |
|
Let's have a look at the code.
|
|
Now before we run this code please note that you need to do following things.
Now lets make some modifications in our previous code. You can embed HTML tags into PHP to define the properties of your contents on serverside. |
|
<html> <head> <title>Hello World</title> </head> <body> <?php echo "<b>"."Hello"." World"."</b><br>";/* <b> is a HTML tag for printing text in BOLD */ /* '.' is a PHP operator for joining (concatenating) two strings.*/ /* <br> is a HTML tag for changing it to new line.*/ printf ("hi"); //a 'c' type function to print strings. ?> </body> </html> |
|
Run this code in similar manner after saving it and you will see some difference.
This way we can generate HTML using PHP code. But this is not a good practice to generate unnecessary HTML code using PHP. |
|
Well I think by this tutorial you would have learned to write and execute basic PHP programs and execute them over Apache on the local machine. You'll be learning more language grammar and syntax in the upcoming tutorials. Thank you. |
|
Spoken Tutorials are a part of the Talk to a Teacher project,coordinated by www.spoken-tutorial.org, supported by the National Mission on Education through ICT, MHRD, Government of India. More information on the same is available at the following link http://spoken-tutorial.org/NMEICT-Intro. The script for this tutorial has been contributed by Abhishek Srivastav from SASTRA University and myself. This is Anurag Jain from SASTRA University Thanjavur, signing off. Thank you for watching. |