I have:
<?php
function _dump($var, $name = "", $return = false){
$output = "<div>";
if (!is_array($var) && !is_object($var)) {
$output .= 'Var name: '.$name.'<br>';
$output .= 'Type: '.gettype($var).'<br>';
$output .= 'Length: '. strlen((string) $var).'<br>';
$output .= 'Value: '.$var.'<br>';
} else{
$output .= 'Var '.$name.' is an '.gettype($var).
' with length '.count((array) $var).
' and the values is listed bellow:<br>';
foreach($var as $k => $v){
$output .= '<div style="margin-left:10px;">'.
_dump($v, $k, true).'</div>';
}
}
$output .= "</div>";
if($return)
return $output;
else echo $output;
}
$backtrace = debug_backtrace();
foreach($backtrace as $b){
_dump($b['args'], "Args");
echo '<hr>';
}
?>
When $var is an array it prints the array values as expected, but raises a Notice: "array to string conversion on line 8". And when within $var($b['args']) there is objects it raises Fatal Error: "Object of class __PHP_Incomplete_Class could not be converted to string on line 8".
The issue, i think, is not the "__PHP_Incomplete_Class" thing but the "could not be converted to string on line 8", because i am already doing "if(!is_array() && !is_object())". So, if i am checking it, why is this raising notices and errors?
Any ideas?
This is the exact iteration from debug_bactrace() that is raising exceptions:
Array
(
[file] => /home/gabriel/Projects/realinvest/engine/class.system.php
[line] => 93
[function] => call_user_func_array
[args] => Array
(
[0] => Array
(
[0] => __PHP_Incomplete_Class Object
(
[__PHP_Incomplete_Class_Name] => Procedures
[system:protected] => System Object
(
[controller:protected] => users
[method:protected] => register
[args:protected] => Array
(
[0] => 1
)
[cpath:protected] => /var/www/html/realinvest//controllers/
)
[module:Controller:private] => procedures
[method:Controller:private] => register
[model:protected] => __PHP_Incomplete_Class Object
(
[__PHP_Incomplete_Class_Name] => ModelProcedures
[primarykey:Model:private] => id
[table:Model:private] => procedures
[dbclass:protected] => __PHP_Incomplete_Class Object
(
[__PHP_Incomplete_Class_Name] => Dbclass
[dbhost:Dbclass:private] => localhost
[dbname:Dbclass:private] => processos_real
[dbuser:Dbclass:private] => root
[dbpass:Dbclass:private] => h7t846m2
[dbtype:Dbclass:private] => mysql
[cnnInfo:Dbclass:private] => stdClass Object
(
[info] => No connection info.
)
[connection:Dbclass:private] =>
[queryerror] =>
[datatypes:Dbclass:private] => Array
(
[boolean] => 5
[integer] => 1
[double] => 2
[string] => 2
[resource] => 3
)
[transaction_mode:Dbclass:private] =>
[lastresult:Dbclass:private] =>
[error] => 0
)
[sql:protected] => __PHP_Incomplete_Class Object
(
[__PHP_Incomplete_Class_Name] => Sql
[table:Sql:private] => procedures
[sqlstring:Sql:private] => SELECT * FROM `procedures` WHERE procedures.`id`= ?
[sqlvalues:Sql:private] => Array
(
[id] => 1
)
)
)
)
[1] => register
)
[1] => Array
(
[0] => 1
)
)
)