Function calls and strings

This is a discussion on Function calls and strings within the PHP General forums, part of the PHP Programming Forums category; Hello. PHP possesses what the manual calls "complex syntax" for allowing one to include non-trivial expressions in ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-11-2003
Ney andré de mello zunino
 
Posts: n/a
Default Function calls and strings

Hello.

PHP possesses what the manual calls "complex syntax" for allowing one to
include non-trivial expressions in strings, e.g.:

$s = "The result is {$results[$foo]}.";

I seek to find out whether PHP also has a syntax to allow function calls
within a string, so that explicit concatenation is not needed. E.g.:

something like:

$s = "The result is {getResult($foo)}.";

as opposed to

$s = "The result is " . getResult($foo) . ".";

If that is not possible, I would appreciate if someone could suggest the
rationale.

Thank you,

--
Ney André de Mello Zunino
Reply With Quote
  #2 (permalink)  
Old 09-14-2003
Curt Zirzow
 
Posts: n/a
Default Re: [PHP] Function calls and strings

* Thus wrote Ney André de Mello Zunino (zunino@unu.edu):

> I seek to find out whether PHP also has a syntax to allow function calls
> within a string, so that explicit concatenation is not needed. E.g.:
>
> something like:
>
> $s = "The result is {getResult($foo)}.";
>
> as opposed to
>
> $s = "The result is " . getResult($foo) . ".";
>
> If that is not possible, I would appreciate if someone could suggest the
> rationale.


How do I tell it NOT to call the function, i want to just store
this in a string:

$s = "The result is {getResult(\$foo)}.";
echo $s;

---
The result is {getResult($foo)).
---


Curt
--
"I used to think I was indecisive, but now I'm not so sure."
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:32 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0