Solved

function calling

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

776 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