bonjour, j'ai un problème dans ma fonction debug du tuto "création d'un site de A à Z". Il lorsque je clique sur le lien qui m'affiche lorsque j'utilise cette fonction, il me marque 2 messages d'erreurs:
"Notice: Undefined index: file in C:\Users\Danny\Documents\siteweb local\EasyPHP-5.3.8.1\www\site_ppo\core\functions.php on line 11"
et
"Notice: Undefined index: line in C:\Users\Danny\Documents\siteweb local\EasyPHP-5.3.8.1\www\site_ppo\core\functions.php on line 11"
Je crois que c'est parce qu'il ne reconnait pas "$debug[0]'file']" et "$debug[0]'line']"
voici le code de ma fonction debug:
<?php
function debug($var){
if(Conf::$debug>0){
$debug = debug_backtrace();
echo ' <p> </p><p><a href="#" onclick="$(this).parent().next(\'ol\').slideToggle(); return false;"><strong>'.$debug[0]'file'].' </strong> ligne '.$debug[0]'line'].'</a></p>';
echo '<ol style="display:none;">';
foreach ($debug as $k => $v){
if($k > 0){
echo '<li><strong>'.$v'file'].' </strong> ligne '.$v'line'].'</li>';
}
}
echo '</ol>';
echo '<pre>';
print_r($var);
echo '</pre>';
}
}
merci de vos réponse.
Si tu fais un var_dump($debug); après l'avoir définit tu obtiens quoi?
Et fait un var_dump($v); pour voir ce que contient $v dans ton foreach.
voici le var_dump($v);
array (size=4)
0 =>
array (size=4)
'file' => string 'C:\wamp\www\8888\controller\UsersController.php' (length=47)
'line' => int 18
'function' => string 'debug' (length=5)
'args' =>
array (size=1)
0 =>
object(stdClass)[10]
...
1 =>
array (size=5)
'function' => string 'login' (length=5)
'class' => string 'UsersController' (length=15)
'object' =>
object(UsersController)[4]
public 'request' =>
object(Request)[2]
...
private 'vars' (Controller) =>
array (size=0)
...
public 'layout' => string 'default' (length=7)
private 'rendered' (Controller) => boolean false
public 'Session' =>
object(Session)[5]
...
public 'Form' =>
object(Form)[6]
...
public 'User' =>
object(User)[7]
...
'type' => string '->' (length=2)
'args' =>
array (size=0)
empty
2 =>
array (size=4)
'file' => string 'C:\wamp\www\8888\core\Dispatcher.php' (length=36)
'line' => int 21
'function' => string 'call_user_func_array' (length=20)
'args' =>
array (size=2)
0 => &
array (size=2)
...
1 => &
array (size=0)
...
3 =>
array (size=7)
'file' => string 'C:\wamp\www\8888\webroot\index.php' (length=34)
'line' => int 15
'function' => string '__construct' (length=11)
'class' => string 'Dispatcher' (length=10)
'object' =>
object(Dispatcher)[1]
public 'request' =>
object(Request)[2]
...
'type' => string '->' (length=2)
'args' =>
array (size=0)
empty
C:\wamp\www\8888\core\Dispatcher.php 1.21
array (size=4)
0 =>
array (size=4)
'file' => string 'C:\wamp\www\8888\controller\UsersController.php' (length=47)
'line' => int 18
'function' => string 'debug' (length=5)
'args' =>
array (size=1)
0 =>
object(stdClass)[10]
...
1 =>
array (size=5)
'function' => string 'login' (length=5)
'class' => string 'UsersController' (length=15)
'object' =>
object(UsersController)[4]
public 'request' =>
object(Request)[2]
...
private 'vars' (Controller) =>
array (size=0)
...
public 'layout' => string 'default' (length=7)
private 'rendered' (Controller) => boolean false
public 'Session' =>
object(Session)[5]
...
public 'Form' =>
object(Form)[6]
...
public 'User' =>
object(User)[7]
...
'type' => string '->' (length=2)
'args' =>
array (size=0)
empty
2 =>
array (size=4)
'file' => string 'C:\wamp\www\8888\core\Dispatcher.php' (length=36)
'line' => int 21
'function' => string 'call_user_func_array' (length=20)
'args' =>
array (size=2)
0 => &
array (size=2)
...
1 => &
array (size=0)
...
3 =>
array (size=7)
'file' => string 'C:\wamp\www\8888\webroot\index.php' (length=34)
'line' => int 15
'function' => string '__construct' (length=11)
'class' => string 'Dispatcher' (length=10)
'object' =>
object(Dispatcher)[1]
public 'request' =>
object(Request)[2]
...
'type' => string '->' (length=2)
'args' =>
array (size=0)
empty
C:\wamp\www\8888\webroot\index.php 1.15
array (size=4)
0 =>
array (size=4)
'file' => string 'C:\wamp\www\8888\controller\UsersController.php' (length=47)
'line' => int 18
'function' => string 'debug' (length=5)
'args' =>
array (size=1)
0 =>
object(stdClass)[10]
...
1 =>
array (size=5)
'function' => string 'login' (length=5)
'class' => string 'UsersController' (length=15)
'object' =>
object(UsersController)[4]
public 'request' =>
object(Request)[2]
...
private 'vars' (Controller) =>
array (size=0)
...
public 'layout' => string 'default' (length=7)
private 'rendered' (Controller) => boolean false
public 'Session' =>
object(Session)[5]
...
public 'Form' =>
object(Form)[6]
...
public 'User' =>
object(User)[7]
...
'type' => string '->' (length=2)
'args' =>
array (size=0)
empty
2 =>
array (size=4)
'file' => string 'C:\wamp\www\8888\core\Dispatcher.php' (length=36)
'line' => int 21
'function' => string 'call_user_func_array' (length=20)
'args' =>
array (size=2)
0 => &
array (size=2)
...
1 => &
array (size=0)
...
3 =>
array (size=7)
'file' => string 'C:\wamp\www\8888\webroot\index.php' (length=34)
'line' => int 15
'function' => string '__construct' (length=11)
'class' => string 'Dispatcher' (length=10)
'object' =>
object(Dispatcher)[1]
public 'request' =>
object(Request)[2]
...
'type' => string '->' (length=2)
'args' =>
array (size=0)
empty
stdClass Object
(
[id] => 1
[login] => admin
[password] => d033e22ae348aeb5660fc2140aec35850c4da997
[role] => admin
)