Calling a function outside of If-segment

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
Ofta
Forum Newbie
Posts: 3
Joined: Tue Apr 17, 2007 5:58 am

Calling a function outside of If-segment

Post by Ofta »

Hey!

I need to call a function from the inside of an If-segment and it doesnt seem to work.

Code: Select all

function A() { echo 'Hey'; }
 
if (!isset($B)) { '.A().' }
Can anyone help me? :(
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Re: Calling a function outside of If-segment

Post by Oren »

Code: Select all

if (!isset($B)) A();  
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Calling a function outside of If-segment

Post by Jonah Bron »

Code: Select all

<?php
function A(){
  return 'Hey';
}
if (!isset($B)) echo A();
?>
Post Reply