It can be any text inside quotes (single or double): $x = "Hello!" Īn integer data type is a non-decimal number between -2,147,483,648 and 2,147,483,647. Array ( array("I", "am", "an", "array") )Ī string is a sequence of characters.Variables can store data of different types such as: Several examples are listed below, for a complete list see the PHP documentation site. The reason for this is that the language itself has already defined those variables and they have are used for special purposes. PHP has several special keywords that, while they are "valid" variable names, cannot be used for your variables. Variable names can only contain letters, numbers, or underscores (A-z, 0-9, and _).Variable names can only start with an upper or lowercase letter or an underscore ( _).Variable declarations starts with $, followed by the name of the variable.To assign a variable, use the = operator, with the name of the variable on the left and the expression to be evaluated on the right. Variables are the main way to store information in a PHP program.Īll variables in PHP start with a leading dollar sign like $variable_name. $NAME and $NaMe are both treated as different variables: " In the example below, only the first statement is valid and will display the value of the $name variable. ![]() However, all variable names are case sensitive. In the example below, all three echo statements are valid: " ĮcHo "Enjoy all of the ad-free articles" The output of that would be: Developer NewsĪll keywords, classes, and functions are NOT case sensitive. Here's a simple script that uses the built-in echo function to output the text "The Best PHP Examples" to the page: Also, PHP statements end with a semicolon ( ). PHP scripts can be placed anywhere in a document, and always start with.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |