Solved

function calling

Posted on 2008-06-19
3
214 Views
Last Modified: 2010-04-21
hello Experts!
interesting question:

why if i call function like that:

echo "<table><tr><td>";
some_function($some_var);
echo "</td></tr></table>";

it output at the sell of the table.

but if i call function like that:

echo "<table><tr><td>".some_function($some_var)."</td></tr></table>";

it displays not in the table but somwhere at the page

?
0
Comment
Question by:nzrubin
3 Comments
 
LVL 49

Accepted Solution

by:
Roonaan earned 20 total points
ID: 21828845
Hello nzrubin,

This is because some_function($some_var) is outputing its own data. You would have to have some_function to return a string, and not output anything.
Then
echo "<table><tr><td>";
echo some_function($some_var);
echo "</td></tr></table>";

will behave the same as
echo "<table><tr><td>".some_function($some_var)."</td></tr></table>";

Regards,

Roonaan
0
 
LVL 2

Expert Comment

by:loki23
ID: 21828864
in order for the concatenation to work, the function would have to be evaluated BEFORE the string is echoed, therefore, if the function uses it's own echo statement, instead of a return statement it will echo in the function first and then process the first echo statement
0
 
LVL 4

Author Closing Comment

by:nzrubin
ID: 31469051
thanks i got it :)
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now