FAQ
Is there any way to do something like:

<?php
("str_replace")("a", "b", "aaa");
?>

?

One of the problems that I must keep "str_replace" on the same line...The
only solution I see is call_user_func, but I would like to know if you guys
might have a clue =]
Tried looking on the manual, sadly didn't found anything

Thanks, Daniel

Search Discussions

  • Andrea Giammarchi at Mar 28, 2009 at 12:51 pm
    I miss the utility to do stuff like that ... seriously ... but in any case:

    <?php
    echo ($f = 'str_replace') ? $f("a", "b", "aaa") : null;
    ?>

    where echo is optional.

    Regards

    Date: Sat, 28 Mar 2009 15:26:18 +0300
    From: danondaniel@gmail.com
    To: php-general@lists.php.net
    Subject: [PHP] Calling function on the same line?

    Is there any way to do something like:

    <?php
    ("str_replace")("a", "b", "aaa");
    ?>

    ?

    One of the problems that I must keep "str_replace" on the same line...The
    only solution I see is call_user_func, but I would like to know if you guys
    might have a clue =]
    Tried looking on the manual, sadly didn't found anything

    Thanks, Daniel
    _________________________________________________________________
    More than messages–check out the rest of the Windows Live™.
    http://www.microsoft.com/windows/windowslive/
  • Virgilio Quilario at Mar 28, 2009 at 5:06 pm

    I miss the utility to do stuff like that ... seriously ... but in any case:

    <?php
    echo ($f = 'str_replace') ? $f("a", "b", "aaa") : null;
    ?>

    where echo is optional.

    Regards
    you mean this
    <?= ($f = 'str_replace') ? $f("a","b","aaa") : null; ?>

    virgil
    http://www.jampmark.com
  • Andrea Giammarchi at Mar 28, 2009 at 6:08 pm
    I don't , I mean if the function is not str_replace you do not necesary need the echo (array_push, as example)
    This notation:
    <?=
    is deprecated since dunno how long ago ... strongly not suggested
    Date: Sun, 29 Mar 2009 01:06:16 +0800
    Subject: Re: [PHP] Calling function on the same line?
    From: virgilio.quilario@gmail.com
    To: an_red@hotmail.com
    CC: php-general@lists.php.net
    I miss the utility to do stuff like that ... seriously ... but in any case:

    <?php
    echo ($f = 'str_replace') ? $f("a", "b", "aaa") : null;
    ?>

    where echo is optional.

    Regards
    you mean this
    <?= ($f = 'str_replace') ? $f("a","b","aaa") : null; ?>

    virgil
    http://www.jampmark.com
    _________________________________________________________________
    Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

    http://www.microsoft.com/windows/windowslive/products/photos.aspx
  • Andrea Giammarchi at Mar 28, 2009 at 6:09 pm
    How do you pass that string?
    If you replace via other file, you do not need to use strings, just call the function.
    If you are parsing a variable, you do not need the inline ...
    $_GET['function']("a", "b", "aaa");
    if the query string is &function=str_replace

    I do not get the problem at all specially now that you do not need variables ... and if you will end up with eval, you are doing something wrong.

    Regards



    Date: Sat, 28 Mar 2009 17:09:15 +0300
    Subject: Re: [PHP] Calling function on the same line?
    From: danondaniel@gmail.com
    To: an_red@hotmail.com

    Thank you for trying to help, But I am trying to do it without variables.... =[

    On Sat, Mar 28, 2009 at 3:51 PM, Andrea Giammarchi wrote:




    I miss the utility to do stuff like that ... seriously ... but in any case:



    <?php

    echo ($f = 'str_replace') ? $f("a", "b", "aaa") : null;

    ?>



    where echo is optional.



    Regards




    Date: Sat, 28 Mar 2009 15:26:18 +0300
    From: danondaniel@gmail.com
    To: php-general@lists.php.net
    Subject: [PHP] Calling function on the same line? >
    Is there any way to do something like: >
    <?php
    ("str_replace")("a", "b", "aaa");
    ?> >
    ? >
    One of the problems that I must keep "str_replace" on the same line...The
    only solution I see is call_user_func, but I would like to know if you guys
    might have a clue =]
    Tried looking on the manual, sadly didn't found anything >
    Thanks, Daniel


    _________________________________________________________________

    More than messages–check out the rest of the Windows Live™.

    http://www.microsoft.com/windows/windowslive/

    _________________________________________________________________
    News, entertainment and everything you care about at Live.com. Get it now!
    http://www.live.com/getstarted.aspx

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-general @
categoriesphp
postedMar 28, '09 at 12:26p
activeMar 28, '09 at 6:09p
posts5
users3
websitephp.net

People

Translate

site design / logo © 2022 Grokbase