echo within function problem...help appreciated

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
scarface222
Forum Contributor
Posts: 354
Joined: Thu Mar 26, 2009 8:16 pm

echo within function problem...help appreciated

Post 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']);
iamngk
Forum Commoner
Posts: 50
Joined: Mon Jun 29, 2009 2:20 am

Re: echo within function problem...help appreciated

Post by iamngk »

really i cannot guess, what would be the problem.

have you tryed with die() method ?
unibroue
Forum Newbie
Posts: 4
Joined: Thu Jul 09, 2009 3:09 pm

Re: echo within function problem...help appreciated

Post by unibroue »

try «return»

function aa()
{
if(0<1)
return "Youre right!"
}
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: echo within function problem...help appreciated

Post 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();
Post Reply