Skip to content

Latest commit

 

History

History
41 lines (22 loc) · 683 Bytes

File metadata and controls

41 lines (22 loc) · 683 Bytes

PHPHandlingObjectInsideArrayFunc

PHP execute data in object inside the array function

  Class Person {
 	
   public function name( $name) { return $name; }	
   
   public function cc() { return 123; }
   
  }
 
 function data() {
 	
   return [
 	
 	 'request' => function( ) { 
 	 	
 	 	$name = new Person();
 	  
 		return implode('', [ $name->name('na') , $name->cc() ]);
 		
 	 },
 	 'get' => function() : int { return (int) 1230; }
 	
 	];
 	
 }

  var_dump( data()["request"]());

 // Result: string(5) "na123"


Reference:
https://github.com/PHPWine/PHPVanilla/blob/main/Crud/Vanilla.php
https://github.com/PHPWine/PHPVanilla/tree/main