0% found this document useful (0 votes)
3 views3 pages

PHP Class Introspection and Serialization

Uploaded by

prajwal914672
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

PHP Class Introspection and Serialization

Uploaded by

prajwal914672
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Practical No: 9

Introspection
<?php

class Rectangle

var $dim1 = 2;

var $dim2 = 10;

function Rectangle ($dim1,$dim2)

$this->dim1 = $dim1;

$this->dim2 = $dim2;

function area()

return $this->dim1*$this->dim2;

function display ()

// any code to display info

$S = new Rectangle(4,2);

//get the class varibale i.e properties

$class_properties = get_class_vars ("Rectangle");


//get object properties

$object_properties = get_object_vars ($S);

//get class methods

$class_methods = get_class_methods ("Rectangle");

//get class corresponding to an object

$object_class = get_class ($S);

print_r($class_properties);

echo "<br>";

print_r ($object_properties);

echo "<br>";

print_r ($class_methods);

echo "<br>";

print_r($object_class);

?>

Output:

Serialization
<!DOCTYPE html>

<html>

<body>

<?php

echo " <h4>Serializing the array</h4></br>";

$data = serialize(array("Red", "Green", "Blue"));


echo $data . "<br>";

echo " <h4>Unserialziing the array</h4></br>";

$test = unserialize($data);

var_dump($test);

?>

</body>

</html>

Output

You might also like