Solved

function calling

Posted on 2008-06-19
3
220 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
The viewer will learn how to dynamically set the form action using jQuery.
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…

691 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