Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

prints in code

Hello everyone! More recently started learning framework. Made a small skeleton with tools. But I can not understand, how do I know the contents of the variable? For example here: https://github.com/uonick/ph-store/blob/master/app/models/users.php#L4 For example, I write here:

$new = 666;
print_r($new)

But it does not work. Just a white screen Tell me how to be?



36.4k
edited Dec '14

you must disable view to result, for example in controller

 $this->view->disable();


931

And to do it every time? How i can then turn on / off developer mode (write a handler for example)



36.4k
Accepted
answer

This is just opnion . In file index.php you create function php look like

    unction d($object, $kill = true)
{
    echo '<pre style="text-aling:left">';
    print_r($object);
    if ($kill) {
        die('END');
    }
    echo '</pre>';
}

Then you call it

d($nice)


931

Hey! Thanks for the answer! But it does not work. For sure I am doing something wrong =) Controller:

<?php

class IndexController extends ControllerBase{

    public function indexAction(){
        $this->view->disable();
    }

}

Model:

<?php

class Users extends \Phalcon\Mvc\Model{
    $var=6666;
    echo '<pre>';
        print_r($var);
    echo '</pre>';
}

White page =(

If I'm just doing a quick output - I just echo it then call exit() right after. Not a good permanent solution, but it's effective if all you need is something quick-n-dirty.



931

whether it is necessary in this case to turn off the output to a template?



30.7k
    $var=6666;
    echo '<pre>';
        print_r($var);
    echo '</pre>';

that code should be located in the controller action you are calling ...



931

This need is often needed in different parts of my code, it turns out that it is impossible to know most of the values of the code?