32,000+ SUBSCRIBERS CAN'T GO WRONG !!!

phpans
GET TOP ARTICLES, SNIPPETS, SCRIPTS IN YOUR INBOX FOR FREE!

Delivered by GET EMAIL UPDATES FeedBurner
We always respect your privacy and take protecting it seriously.
We won't Spam You

PHP Basic Syntax

, 0,
PHP Basic Syntax
You must create a PHP file (.php) to execute PHP code otherwise it'll not work. PHP code start with <?php tag and close with ?> tag. And every line complete with semicolon ( ; ) . Ok now create a php file and open your file into notepad or other IDE (editor) and write down below code
<?php
echo "Hello World! This is my first PHP project";
?>

Open WWW
Now save you page name as hello.php into your localserver's htdocs (XAMPP) or www (WAMP) folder. Now open your browser you will get output like this.
Hello World
You can also use short tags to write PHP like
<?= "Hello World! This is my first PHP project";?>

or,
<? "Hello World! This is my first PHP project";?>

or,
<script language="php">

echo "Hello World! This is my first PHP project";

</script>

If you use short tag then you have to configer it into php.ini and enable short_open_tag.
The first way is best for write PHP code and it use most developers.
You can also write PHP code using print . example
<?php
print ("Hello world!");
?>

It'll execute same result like as echo but echo is better then print.

Download PDF
Is this article helpful for you?





captcha

  • Connect
  •       
Top
Create an free account and start learning & sharing! Sign Up