O'Reilly logo

Core PHP Programming: Using PHP to Build Dynamic Web Sites by Leon Atkinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Retrieving Values

To use the value stored in a variable, use it anywhere where a value is required, such as the argument to a function or in an expression. For example, if you wish to print the value to the browser, you can type print($s) to print the value of a variable named s. You can even set a variable with the value of another, such as $s = $t.

If a variable contains a string, you may refer to each character using square brackets. Each character is numbered starting with zero. To refer to the seventh character in the s variable, you would type $s[6]. This notation works both ways, in fact. You can set a single character of a string with an expression like $s[6] ="x". Only the first character of the value on the right-hand side will be used ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required