php function return

Discuss general web development questions. Help others and get help from others.

Moderator: kfury77

php function return

Postby Elygen » Mon Aug 04, 2008 5:16 am

I have not use this method in a long time and can not remember the syntax.
return a function like this
Code: Select all
function x() {
return test<<<
this is a test;
<<< test
}


well its something like this. Does anyone know?

Thanks!!!!
Todd
Elygen
 
Posts: 49
Joined: Wed Oct 12, 2005 4:55 am

Re: php function return

Postby syrupcore » Mon Aug 04, 2008 6:40 am

Not familiar with that <<< syntax >>> at all. What is it you're trying to do?
User avatar
syrupcore
Top Contributor
 
Posts: 917
Joined: Thu Jul 21, 2005 12:58 am
Location: Portland, Oregon, usa

Re: php function return

Postby Elygen » Mon Aug 04, 2008 9:17 pm

This is it

<?php
function x() {
$test = <<<TEST
this is a test;
TEST;
return($test);
}
?>

You can put anything in the middle(where i have this is a test) and it will return. for example you can do

<?php
function ul() {
$ul= <<<ul
<ul>
<li>button1</li>
<li>button2</li>
</ul>
TEST;
return($ul);
}
?>

it will return the orderlist. probably not a good to abuse but for something unimportant it is good.

thanks
Elygen
 
Posts: 49
Joined: Wed Oct 12, 2005 4:55 am


Return to Web Developer Talk

Who is online

Users browsing this forum: No registered users and 1 guest

cron