Welcome Guest, Not a member yet? Register   Sign In
help with boolean
#7

[eluser]Yorick Peterse[/eluser]
[quote author="KrizzAngel" date="1264174356"]constructor?? i dont know if u guys gets what i mean hehe..
i just dont know how "return" value works..
for example i was coding my index() function.
i wrote
Quote:function index()
{
$this->checker();
$this->load->view('home.php');
}

does this mean that if the checker returns true it will continue to load the home page?? what if its false..
how can i express the other code so that it will load another page if its false/[/quote]

The return statement, as the name might suggest, does nothing more than returning a certain value (or whatever it's supposed to return). If you place this statement in a function (as shown below), it will skip everything after the return statement.

Code:
<?php
function cookies()
{
    // This gets executed
    $var = 'hello world';
    return $var;
    // This is ignored
    echo 'Hello planet';
}
?>

The difference between return and echo is that echo outputs it to the screen (or console) whereas return does nothing more than returning it. You can use the return statement as following:

Code:
<?php
    // The function
    function hello_world()
    {
        $message = 'Hello world!';
        return $message;
    }
    // How to use it, method 1
    echo hello_world(); // Outputs: Hello world!

    // Or you can do this
    $some_var = hello_world()
    echo $some_var; // Outputs: Hello world!
?>


Messages In This Thread
help with boolean - by El Forum - 01-21-2010, 09:13 PM
help with boolean - by El Forum - 01-21-2010, 11:04 PM
help with boolean - by El Forum - 01-22-2010, 02:01 AM
help with boolean - by El Forum - 01-22-2010, 03:32 AM
help with boolean - by El Forum - 01-22-2010, 03:51 AM
help with boolean - by El Forum - 01-22-2010, 05:30 AM
help with boolean - by El Forum - 01-22-2010, 07:04 AM
help with boolean - by El Forum - 01-22-2010, 07:14 AM
help with boolean - by El Forum - 01-22-2010, 10:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB