php
  • replace
  • 2015-11-03 109 views 0 likes 
    0

    我试图在php var中替换一个单词,但它并不按我尝试的方式工作。在php中替换word var

    这里是我的代码:

    iframe.src = '<?php echo $app->url("Widget:iframeContent") ?>&domain=' + document.domain; 
    

    它会返回此:

    http://127.0.0.1/livechat/php/app.php?widget-iframe-content&domain=' + document.domain

    这里是我的尝试:

    iframe.src = '<?php echo str_replace("http", "https", $app->url)("Widget:iframeContent") ?>&domain=' + document.domain; 
    

    我想要做的就是更换HTTP与https,但我找不到办法。

    +0

    你找不到'str_replace()'函数? – Barmar

    +0

    什么是“我尝试的方式”?我没有看到任何试图替换一个字。 – Barmar

    回答

    2

    当您将呼叫添加到str_replace时,你搞砸了你拨打url方法的方式;您在通话之外有$app->url的参数。它应该是:

    iframe.src = '<?php echo str_replace("http", "https", $app->url("Widget:iframeContent")) ?>&domain=' + document.domain; 
    
    相关问题