Jump to content


Photo

Function Question


  • Please log in to reply
3 replies to this topic

#1 lilywong

lilywong
  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts

Posted 03 August 2006 - 07:17 AM

<table>
<? echo getName(); ?>
<table>

<?
function getName()
{
  $a = "test";
  return $a;
}

?>

when i echo the function, i should get test, right ? anything wrong there as when i echo i see nothing. thanks.

#2 extrovertive

extrovertive
  • Members
  • PipPipPip
  • Advanced Member
  • 235 posts

Posted 03 August 2006 - 07:30 AM

works fine for me.

Might want to change your <? declaration to <?php

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 03 August 2006 - 11:20 AM

You'll want to define the function first before you use it. So you'll  want to this:
<?php

function getName()
{
    $a = "test";
    return $a;
}

?>

<table>
<?php echo getName(); ?>
<table>


#4 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 03 August 2006 - 11:28 AM

What I tend to do is have all functions at the top of the page, just below <body>
common used functions go into an include

A couple of scripts I built
All the code is at the top

All echo's are below
(Does not work very well when using Ifs to determin the next move
Tell me the problem, I will try tell you the solution




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users