Solved

function calling

Posted on 2008-06-19
3
215 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

911 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

25 Experts available now in Live!

Get 1:1 Help Now