Solved

function calling

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How do I remove "" from json_encode 5 35
PHP $_POST vs asp request 4 56
How to display get_the_terms within a function 3 38
history of pages 7 51
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.  …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to count occurrences of each item in an array.
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 …

739 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