Php Reflection Examples Helpful Utility Functions Checking for the Existence of Classes and Interfaces Using class_exists() and interface_exists() Checking if a class implements an interface obtain by using class_parents(), class_implements(), get_class_methods(), and get_class_variables() in order to obtain information about the built-in ArrayIterator classCreating an object from the Cat class Displaying the Type of a Variable get_class() function returns the class name. get_class_methods() function returns an array of methods defined by the class specified by class_name. Listing Methods and Interfaces Using get_class_methods() get_class_vars() function returns an array of attributes defined in the class specified by class_name. get_declared_classes() function returns an array of all defined classes. If you are not sure which XML APIs might be available Listing Currently Loaded Interfaces and Classes get_declared_interfaces( ) returns an array of all the interfaces currently available to you get_object_vars() function returns an array containing the properties of the attributes. Obtaining Variable Names get_parent_class() function returns the name of the parent class. _exists function Determining Whether An Object Is An Instance Of A Particular Class PHP is_ Functions functions is_int() and is_float() check for specific data types. is it an array, or is it an integer, or is it numeric function is_numeric() checks if the value passed as the argument is numeric Using an is_ function to determine a proper data type Using is_ function to determine a proper data type and then work with it method_exists() function checks to see if a particular method, exists. Checking if a class implements an interface using the Reflection classes

Php Code : Using Is_ Function To Determine A Proper Data Type And Then Work With It

Using is_ function to determine a proper data type and then work with it in php

 
<?php

  $unknownvar = "Hello World";
  echo gettype ($unknownvar) . "<br />";

  if (is_string ($unknownvar)){
    echo "Is a string<br />";
  }

  $mynumber = "1.03";

  $mynumber = settype ($mynumber ,"integer");
  echo $mynumber . "<br />";

  echo (int) $mynumber;

?>