Home / Core PHP (page 2)

Core PHP

PHP 5 Constants

Constants are like variables except that once they are defined they cannot be changed or undefined. PHP Constants A constant is an identifier (name) for a simple value. The value cannot be changed during the script. A valid constant name starts with a letter or underscore (no $ sign before …

Read More »

PHP 5 String Functions

A string is a sequence of characters, like “Hello world!”. PHP String Functions In this chapter we will look at some commonly used functions to manipulate strings. The PHP strlen() function The strlen() function returns the length of a string, in characters. The example below returns the length of the …

Read More »

PHP 5 Data Types

String, Integer, Floating point numbers, Boolean, Array, Object, NULL. PHP Strings A string is a sequence of characters, like “Hello world!”. A string can be any text inside quotes. You can use single or double quotes: Example <?php $x = "Hello world!"; echo $x; echo "<br>"; $x = 'Hello world!'; …

Read More »

PHP 5 echo and print Statements

In PHP there are two basic ways to get output: echo and print. In this tutorial we use echo (and print) in almost every example. So, this chapter contains a little more info about those two output statements. PHP echo and print Statements There are some differences between echo and …

Read More »

PHP 5 Variables

Variables are “containers” for storing information: Example <?php $x=5; $y=6; $z=$x+$y; echo $z; ?> Much Like Algebra x=5 y=6 z=x+y In algebra we use letters (like x) to hold values (like 5). From the expression z=x+y above, we can calculate the value of z to be 11. In PHP these …

Read More »

PHP 5 Basic PHP Syntax

The PHP script is executed on the server, and the plain HTML result is sent back to the browser. Basic PHP Syntax A PHP script can be placed anywhere in the document. A PHP script starts with <?php and ends with ?>: <?php // PHP code goes here ?> The …

Read More »