TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-27-2008, 04:14 AM   #1 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default return keyword

Is this the ONLY bloody keyword to not allow data go up at the top

My problem is, I want to kill "return" in the function scope. I hate it, and it's the only thing I know that will allow me to return data without making it go to the top of the canvas of the page.

PHP Code:

function test() {

echo 
"test";


The above function will always output at the top, after all the rest of the data that is outside the variable scope, please help.. Do not say use Return.
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 06-27-2008, 05:26 AM   #2 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

Sorry, I may be the only one, but I'm not following. What are you trying to do?

Most of the methods and functions I use return data (a lot of those simply because all I want is a boolean response from them). I do use a few that directly output data using echo or other means, and they display that data where ever I want them to, based on where I put the function call.

Edit: I gotta ask why do you hate return? The basic idealogy behind a function is that it returns something, a value, be it boolean, data, etc. Look at PHP's built in functionality. substr() doesn't directly echo data, it returns it to you.
-m
delayedinsanity is offline  
Reply With Quote
Old 06-27-2008, 06:05 AM   #3 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by delayedinsanity View Post
Sorry, I may be the only one, but I'm not following. What are you trying to do?

Most of the methods and functions I use return data (a lot of those simply because all I want is a boolean response from them). I do use a few that directly output data using echo or other means, and they display that data where ever I want them to, based on where I put the function call.

Edit: I gotta ask why do you hate return? The basic idealogy behind a function is that it returns something, a value, be it boolean, data, etc. Look at PHP's built in functionality. substr() doesn't directly echo data, it returns it to you.
-m
Cause it hates eval() | assert()
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 06-27-2008, 10:21 AM   #4 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

I have no idea what your on about. the only thing i can even remotely imagin you can mean is:
PHP Code:
ob_start();
function 
test() { 
    echo 
"test"
}  
test();

$lol ob_get_clean(); 
A wild stab in the dark, but meh.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 06-27-2008, 10:23 AM   #5 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by sketchMedia View Post
I have no idea what your on about.
I cannot use the return keyword in eval(), it doesn't work. And Im speaking with inside the function scope, when I use echo it works, or print, sprintf, printf, fprintf. whatever
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 06-27-2008, 02:58 PM   #6 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

Why do you need to use the return keyword with eval, just out of curiosity
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 06-27-2008, 07:10 PM   #7 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

What are you talking about?

PHP Code:
function test_func()
{
    return 
'return value of the test function';
}

eval(
'$return = test_func();');

echo 
$return
$return will contain exactly the string returned by the function. So, what is the problem? I really don't see why you would want to do such thing anyway...
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 06-27-2008, 07:14 PM   #8 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by xenon View Post
What are you talking about?

PHP Code:
function test_func()
{
    return 
'return value of the test function';
}

eval(
'$return = test_func();');

echo 
$return
$return will contain exactly the string returned by the function. So, what is the problem? I really don't see why you would want to do such thing anyway...
I want the eval() inside the function scope.
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 06-30-2008, 02:53 AM   #9 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

Why not just do this?

PHP Code:
function test_func()
{
    eval(
'$var = "val";');
    return 
$var;
}

echo 
test_func(); 
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 04:49 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design