Friday, April 19, 2013

class_exists() function

4/19/2013

The class_exists() function is used to determine whether or not a class is defined in the script. It returns a boolean value of either TRUE or FALSE.



example.php



<?php
/* 
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.in/
*/

include_once("cart.php");
if(class_exists("cart")){
    $shopping_cart = new cart();
    echo $shopping_cart->store;
} else {
    echo '"cart" class does not exist';
}


?>









cart.php


<?php
/* 
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.in/
*/


class cart {

    public $store = "Spacely Sprockets";
    public $items = array();
}

?>

helpful? Share this

The Editorial Team of 4everTutorials consists of a group of PHP Professionals.

0 comments:

 

© 2014 4everTutorials. All rights resevered.

Back To Top