Jump to content

Archived

This topic is now archived and is closed to further replies.

lilywong

Function Question

Recommended Posts

<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.

Share this post


Link to post
Share on other sites
You'll want to define the function first before you use it. So you'll  want to this:
[code=php:0]<?php

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

?>

<table>
<?php echo getName(); ?>
<table>
[/code]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.