Cast a user defined object


/ Published in: PHP
Save to your folder(s)

Usefull for IDE autocompletion


Copy this code and paste it in your HTML
  1. class MyObject {
  2. /**
  3.   * @param MyObject $object
  4.   * @return MyObject
  5.   */
  6. static public function cast(MyObject $object) {
  7. return $object;
  8. }
  9. }
  10.  
  11. $myObject = MyObject::cast($_SESSION["myObject"]);

URL: http://ch.php.net/manual/en/language.types.type-juggling.php#language.types.typecasting

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.