Читать книгу PHP Programming for Beginners. Key Programming Concepts. How to use PHP with MySQL and Oracle databases (MySqli, PDO) - Sergey D Skudaev - Страница 3

Declaration of variables

Оглавление

A computer program starts with the declaration of variables.

In PHP you do not have to declare a data type. A variable name in PHP is preceded with a $ sign. For example, $n=0; The string of text should be enclosed in either single or double quotation marks. For example:


$firstname=“Alexander’;

Or

$lastname=“Makedonski”;

$name=“Alexander Makedonski”;


As you may have noticed, a line of code in PHP is ended with a semicolon.

It’s always good practice to add comments when writing code, as they will enable you to better understand the meaning later. Also, if someone else reads or modifies your code, comments may be helpful. Comments must be preceded by two back slashes or placed between asterisks and backslashes:

/* this is code comment */

//this is another code comment


All PHP code blocks start with a "<?php” tag and ends with”? >" tag.

PHP Programming for Beginners. Key Programming Concepts. How to use PHP with MySQL and Oracle databases (MySqli, PDO)

Подняться наверх