Joss Posted February 13, 2013 Share Posted February 13, 2013 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 More sharing options...
Joss Posted February 13, 2013 Author Share Posted February 13, 2013 ignore me, I think I have worked it out Link to comment Share on other sites More sharing options...
Soma Posted February 13, 2013 Share Posted February 13, 2013 localSidebarText($firstline); Link to comment Share on other sites More sharing options...
Joss Posted February 13, 2013 Author Share Posted February 13, 2013 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 More sharing options...
Soma Posted February 13, 2013 Share Posted February 13, 2013 Use wire("page")->title if inside scope of a sn.. ERR function. Or with giving it through function call. Link to comment Share on other sites More sharing options...
Joss Posted February 13, 2013 Author Share Posted February 13, 2013 Okay Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now