PHP Basic Syntax

PHP Basic Syntax

PHP is really a simple programming language that have it origin drive from C and Perl programming language, but PHP look more like Java language.

PHP is also handy to used, but before using PHP language, there are some rules that you must learn about the syntax and it make up.

On these post, we are going to teach you the syntax rule you must learn if you must excel with PHP language. These syntax are semicolon and dollar symbol.

Semicolon (;)

You must have notice that every PHP program end with semicolons, as shown below;

$our_website “omokoshaban.com”;.

The simplest and the most common error mostly encounter by the beginner writing PHP program, is that they often forget to add semicolon at the end of the program line, when they forget to add that, PHP will now treat multiple statement as a single statement, as such subject the program not to be understood by PHP, which now led to an error parse message.

So don’t forget to end your program code line with semicolon before you go to another line of instruction.

The Dollar ($) symbol

The Dollar ($) symbol is not only applicable to PHP programming language, but some other programming language.

For example dose that doe write BASIC language use $ symbol to terminate variable names to assign them to a strings.

In writing PHP program, it is compulsory to place $ symbol from the beginning of any variable, the function is that it help the PHP to parse fast, as it is quickly recognize whenever it come across a variable.

See also  Dennis Isong: What Is The Future Of Real Estate In Nigeria?

What you should also understand is that $ symbol is place on any variable, be it numbers, strings, or array. As shown on the example below

<?php

echo ” Today is ” .date(“l”). “.”;

?>

Here’s the latest news.

<?php

echo “<br>”;

echo ” Tomorrow will be ” .date(“l”). “.”;

echo “<br>”;

?>

<script type=”text/javascript”>

document.write(“Today is ” + Date());

</script>

<style>

p{

            text-alignt:center;

            font-family:Helvetica;

            text-color: Green;

}

</style>

<body>

<p> This is the begeninng of my programing, and am expected to develop website from the scratch within one

year. thank you </p>

</body>

<?php

$username= “Fred Smith, Omoko”;

echo $username;

echo “<br>”;

$current_user = $username;

echo $current_user;

$count= 15;

echo “<br>”;

echo $count;

$team = array(‘musa’, ‘adamu’, ‘shuaibu’, ‘James’,’success’,);

echo “<br>”;

echo $team[0];

?>

<?php

$oxo = array(array(‘x’, ”, ‘o’,),

       array(‘o’,’o’,’x’,),

               array(‘x’,’o’,”,));

               echo “<br />”;

               echo $oxo[1][2];

               echo “<br>”;

               echo 6 – 2;

               echo “<br>”;

               echo 2000000 * 124050604050040506506400650650;

               $count += 1;

               echo “<br>”;

               echo $count;

               echo “<br>”;

?>

<?php

$count= 1000;

echo “This week $count people have viewed your profile”;

$text = ‘my spelling\’s is still atroshus’;

echo “<br>”;

echo $text;

$heading = “Date\tName\tPayment”;

echo “<br>”;

echo $heading;

?>

<?php

$text = “she wrote upon it, \”return to sender\”.”;

echo “<br>”;

echo $text;

?>

That is the syntax you have to remember when working with PHP programing language.

When we compare PHP with python, we can find out that python is a very strict language, they are strict on how programmer will indent and lay out the code, but PHP is not like that it leave that for the choice of the programmer to either use it or not to make indenting and spacing the program. To PHP programmer, logical used of whitespace is globally encouraged in line with up-to-date commenting to assist the programmer understand their code, when they revert back to it, and also assist another programmer when they are to maintain the program code.

See also  Ekiti Bans Traditional Festivals In Towns, Villages

Thanks for reading,

don’t forget if you have any question on suggetion, please leave it on our comment section below.

Be the first to comment

Leave a Reply

Your email address will not be published.


*