Page 1 of 1

echo within function problem...help appreciated

Posted: Fri Jul 10, 2009 12:00 am
by scarface222
Hey guys when I use this function which is activated by a form via the post method located in another page, I use an if statement which error checks and exits with a comment to show the user if there is a problem. However when I call back the function I do not get the exit comment displayed however the exit works and the page exits. Here is an example of the code. Anyone got any ideas?

Check from within function

Code: Select all

if ($count>=1){ 
exit ("you cannot submit twice");
}
and the function call

Code: Select all

echo function($_POST['n'], $_POST['k'], $_POST['t']);

Re: echo within function problem...help appreciated

Posted: Fri Jul 10, 2009 7:01 am
by iamngk
really i cannot guess, what would be the problem.

have you tryed with die() method ?

Re: echo within function problem...help appreciated

Posted: Fri Jul 10, 2009 7:52 am
by unibroue
try «return»

function aa()
{
if(0<1)
return "Youre right!"
}

Re: echo within function problem...help appreciated

Posted: Fri Jul 10, 2009 7:59 am
by jackpf
Hmm...I don't know what your problem is lol.

This works fine

Code: Select all

<?php
    function foo()
    {
        if(0 < 1)
        {
            exit('You have already submitted this form.');
        }
    }
    
    echo foo();