Basic Syntax in php

PHP is quite a simple language with roots in C and Perl, yet it looks more like Java. It is also very flexible, but there are a few rules that you need to learn about its syntax and structure

Semicolons

$x += 10;

The $ symbol

<?php
 $mycounter = 1;
 $mystring = "Hello";
 $myarray = array("One", "Two", "Three");
?>

Variables

String variables

$username = “Fred Smith”;

first PHP program

<?php 
 $username = "Fred Smith";
 echo $username;
 echo "<br>";
 $current_user = $username;
 echo $current_user;
?>

Leave a Comment