Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 09:46 pm EST
Geeklog Forums
Static Pages - return statement
Status: offline
gbarnes
Forum User
Newbie
Registered: 12/07/03
Posts: 4
I used PHP in a static page. I originally used the echo command - this produced the result I expected but outside the block as indicated by the documentation.
However, when I changed my echo commands to return commands I just get a mess.
Any thoughts?
However, when I changed my echo commands to return commands I just get a mess.
Any thoughts?
12
9
Quote
Status: offline
gbarnes
Forum User
Newbie
Registered: 12/07/03
Posts: 4
I am using return. I have read the page. I also followed the rules: -
You will need to enable the use of PHP for each individual page.
Don't include your PHP code in tags.
Don't use echo or print.
Use return to return the content you want to be displayed.
BUT when I use RETURN it does NOT work. Echo produces the best result(if out of the block as indicated in the documentation).
If I am missing something else then I would be grateful for it to be pointed out to me. I am using Return with no success while using echo with some resonably good results.
You will need to enable the use of PHP for each individual page.
Don't include your PHP code in tags.
Don't use echo or print.
Use return to return the content you want to be displayed.
BUT when I use RETURN it does NOT work. Echo produces the best result(if out of the block as indicated in the documentation).
If I am missing something else then I would be grateful for it to be pointed out to me. I am using Return with no success while using echo with some resonably good results.
11
10
Quote
Status: offline
exaurdon
Forum User
Regular Poster
Registered: 08/13/03
Posts: 107
This is really basic, but just to check, you are aware you can only use a single return statement in your php right? (Return in a php staticpage should print the given value, and then will end the php)
Exaurdon~
Exaurdon~
9
12
Quote
Status: offline
gbarnes
Forum User
Newbie
Registered: 12/07/03
Posts: 4
It is very basic but I am also a newbie. I had noticed my first return statment worked but ignored it in blind faith.
As I said I needed it pointed out. I will no need to re-evaluate what I am trying to do - though echo works VERY well - if outside the block for my task.
THANKS
As I said I needed it pointed out. I will no need to re-evaluate what I am trying to do - though echo works VERY well - if outside the block for my task.
THANKS
13
9
Quote
Status: offline
exaurdon
Forum User
Regular Poster
Registered: 08/13/03
Posts: 107
Hello again,
Generally, what you do for php mode, is collect all of the text you want into a variable, and then return the variable at the end of the script.
Example: (Assuming you want to print 'hello world!')
$echotext .= " World";
$echotext .= "!";
return $echotext;
(Obviously, that could also be done in a single line, but I was just trying to show an example of how you can stack a variable and return it)
Exaurdon~
Generally, what you do for php mode, is collect all of the text you want into a variable, and then return the variable at the end of the script.
Example: (Assuming you want to print 'hello world!')
Text Formatted Code
$echotext = "Hello";$echotext .= " World";
$echotext .= "!";
return $echotext;
(Obviously, that could also be done in a single line, but I was just trying to show an example of how you can stack a variable and return it)
Exaurdon~
12
10
Quote
All times are EST. The time is now 09:46 pm.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content