Hi all
In PHP created two functions and another section of code to call these function. However what I'm finding is that the first function is been called (which is wrong) the second function isn't been called (which is correct). But the code calling the functions are not been called. I' using PHPed if that helps.
I'm new to PHP and is trying to set something up using PHP and mySQL.
Any and all help will be greatly appreciated.
Help with functions...pleasse!
Moderator: General Moderators
- RandomEngy
- Forum Contributor
- Posts: 173
- Joined: Wed Jun 26, 2002 3:24 pm
- Contact:
Help with functions...pleasse! 2
The general format of the code is like this....
function a()
{
echo "a-in";
// some other code
echo "a-out";
return(1); // exmaple return value
}
function b()
{
echo "b - in";
// some other code
echo "b-out"
return(0); // exmaple return value
}
// code to call functions
if (a)
{
ehco "a-called";
}
if (b)
{
ehco "b-called";
}
// the problem is that all I ever see is a-in a-out nothing else.
// hope this helps
function a()
{
echo "a-in";
// some other code
echo "a-out";
return(1); // exmaple return value
}
function b()
{
echo "b - in";
// some other code
echo "b-out"
return(0); // exmaple return value
}
// code to call functions
if (a)
{
ehco "a-called";
}
if (b)
{
ehco "b-called";
}
// the problem is that all I ever see is a-in a-out nothing else.
// hope this helps
- RandomEngy
- Forum Contributor
- Posts: 173
- Joined: Wed Jun 26, 2002 3:24 pm
- Contact:
I noticed a few things, like ehco instead of echo, no semicolon after echo b-out, and a instead of a(). The parenthesis tell PHP that a() is a function.
Try something like:
Try something like:
Code: Select all
$check = a();
if($check)
echo "a has run";
$check = b();
if($check)
echo "b has run";In your example
Is "a" supposed to be a variable?
Later on,
BDKR
Code: Select all
if(a)
{ echo "a-called"; }Later on,
BDKR
Help with functions...pleasse! 3
sorry for the crap syntax.
haven't programmed in C/C++ for years...I know about a() for functions instead of a. The syntax is correct. It's just the flow of execution that seems to be the problem. Learning to touch-type at the moment everything I type seems to come out crap.
haven't programmed in C/C++ for years...I know about a() for functions instead of a. The syntax is correct. It's just the flow of execution that seems to be the problem. Learning to touch-type at the moment everything I type seems to come out crap.