note 52952 modified in function.call-user-func by danbrown
| From: | danbrown@php.net | Date: | Sat, 19 Jul 2008 21:08:04 +0000 |
| Subject: | note 52952 modified in function.call-user-func by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-141742@lists.php.net to get a copy of this message | ||
It seems like call_user_func() can not be used to create Objects via the new Command.
The Following example dosen't work:
<?php
include_once(class_".$type.".php");
$object = new call_user_func ('bdv_'.$type);
?>
But this works:
<?php
include_once(class_".$type.".php");
$constr = 'bdv_'.$type;
$object = new $constr();
?>
--was--
It seems like call_user_func() can not be used to create Objects via the new Command.
The Following example dosen't work:
<?
include_once(class_".$type.".php");
$object = new call_user_func ('bdv_'.$type);
?>
But this works:
<?
include_once(class_".$type.".php");
$constr = 'bdv_'.$type;
$object = new $constr();
?>
http://php.net/manual/en/function.call-user-func.php