O'Reilly logo

Core PHP Programming, Third Edition 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

11.1. Data Types, Constants, and Variables

These functions check the status of a variable, change its type, or return a value as a particular data type.

value constant(string name)

Use constant (Listing 11.1) to fetch the value of a constant. This offers the ability to specify a constant with a variable.

Listing 11.1. constant
<?php
    function getDatabaseProperty($property)
    {
        return(constant("DATABASE_$property"));
    }

    define("DATABASE_HOST", "localhost");
    define("DATABASE_USER", "httpd");
    define("DATABASE_PASSWORD", "");
    define("DATABASE_NAME", "freetrade");

    print(getDatabaseProperty('HOST'));
?>

boolean ctype_alnum(string text)

The ctype_alnum function tests whether every character in the given string is in the set of all digits and letters, ...

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