• PHP Comments
    Comments in PHP A comment in PHP code is a line that is not executed as a part of the program. Its only purpose is to be read by someone who is looking at the code. Comments can be used to: Let others understand your code Remind yourself of what you did - Most programmers have experienced coming back to their own work a year or two later and having to re-figure out what they did. Comments...
    0 Commentaires 0 Parts 4KB Vue 0 Aperçu
  • PHP Multiline Comments
    Multi-line Comments Multi-line comments start with /* and end with */. Any text between /* and */ will be ignored. The following example uses a multi-line comment as an explanation: ExampleGet your own PHP Server Multi-line comment as an explanation: /* The next statement will print a welcome message */ echo "Welcome Home!"; Try it Yourself...
    0 Commentaires 0 Parts 4KB Vue 0 Aperçu
  • PHP Variables
    Variables are "containers" for storing information. Creating (Declaring) PHP Variables In PHP, a variable starts with the $ sign, followed by the name of the variable: ExampleGet your own PHP Server $x = 5; $y = "John" Try it Yourself » In the example above, the variable $x will hold the value 5, and the variable $y will hold the...
    0 Commentaires 0 Parts 5KB Vue 0 Aperçu
  • PHP Variables Scope
    PHP Variables Scope In PHP, variables can be declared anywhere in the script. The scope of a variable is the part of the script where the variable can be referenced/used. PHP has three different variable scopes: local global static Global and Local Scope A variable declared outside a function has a GLOBAL SCOPE and can only be accessed outside a function: ExampleGet...
    0 Commentaires 0 Parts 7KB Vue 0 Aperçu
  • PHP echo and print Statements
    With PHP, there are two basic ways to get output: echo and print. In this tutorial we use echo or print in almost every example. So, this chapter contains a little more info about those two output statements. PHP echo and print Statements echo and print are more or less the same. They are both used to output data to the screen. The...
    0 Commentaires 0 Parts 6KB Vue 0 Aperçu
  • PHP Data Types
    PHP Data Types Variables can store data of different types, and different data types can do different things. PHP supports the following data types: String Integer Float (floating point numbers - also called double) Boolean Array Object NULL Resource Getting the Data Type You can get the data type of any object by using the var_dump() function. ExampleGet your own...
    0 Commentaires 0 Parts 3KB Vue 0 Aperçu
  • PHP Strings
    A string is a sequence of characters, like "Hello world!". Strings Strings in PHP are surrounded by either double quotation marks, or single quotation marks. ExampleGet your own PHP Server echo "Hello"; echo 'Hello'; Try it Yourself » Note There is a big difference between double quotes and single quotes in PHP. Double quotes process special characters, single quotes...
    0 Commentaires 0 Parts 4KB Vue 0 Aperçu
  • PHP - Modify Strings
    PHP has a set of built-in functions that you can use to modify strings. Upper Case ExampleGet your own PHP Server The strtoupper() function returns the string in upper case: $x = "Hello World!"; echo strtoupper($x); Try it Yourself » Lower Case Example The strtolower() function returns the string in lower case: $x = "Hello World!"; echo...
    0 Commentaires 0 Parts 6KB Vue 0 Aperçu
  • PHP - Concatenate Strings
    String Concatenation To concatenate, or combine, two strings you can use the . operator: ExampleGet your own PHP Server $x = "Hello"; $y = "World"; $z = $x . $y; echo $z; Try it Yourself » The result of the example above is HelloWorld, without a space between the two words. You can add a space character like this: Example $x = "Hello"; $y = "World"; $z =...
    0 Commentaires 0 Parts 6KB Vue 0 Aperçu
  • PHP - Slicing Strings
    Slicing You can return a range of characters by using the substr() function. Specify the start index and the number of characters you want to return. ExampleGet your own PHP Server Start the slice at index 6 and end the slice 5 positions later: $x = "Hello World!"; echo substr($x, 6, 5); Try it Yourself » Note The first character has index 0. Slice to the...
    Like
    1
    1 Commentaires 0 Parts 6KB Vue 0 Aperçu