Jump to content

Stupid function problem


Joss
 Share

Recommended Posts

There are times when I think I am going mad.

I have been trying to get a very simple function to work, but I am having trouble passing a variable.

So I have simplified the function to the point of silly but it still does not work.

All I have in it is a word and a variable - the variable is from outside the function.

I have tried:

$firstline = "please say";

function localSidebarText($firstline) {

    echo $firstline;
    echo "hello";
}
localSidebarText();
 
 
and I have tried:
 
$firstline = "please say";

function localSidebarText() {
global $firstline;

    echo $firstline;
    echo "hello";
}
localSidebarText();
 
 
 
And all it outputs is the word "Hello"
 
What am I doing wrong?
 
 
Joss (who is having a really bad night when it comes to anything PW/php shaped)
Link to comment
Share on other sites

Yeah, that was the bit I just realised :)

Just for interest, how can I put $page->title in the function brackets without breaking them?

Like

 function localSidebarText($page->title)

or do I have to always convert them first?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...