简体   繁体   English

替换php var中的单词

[英]Replace word in php var

I'm trying to replace a word in a php var, but it isn't working the way i'm trying. 我正在尝试在php var中替换一个单词,但是它不起作用。

Here's my code: 这是我的代码:

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

It'll return this: 它将返回此:

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

Here's what i tried: 这是我尝试过的:

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

What I want to do is replace the http with https, but I can't find a way to do it. 我想做的是将HTTP替换为https,但是我找不到一种方法。

You messed up the way you're calling the url method when you added the call to str_replace ; 将调用添加到str_replace时,您弄乱了调用url方法的方式; you have the argument to $app->url outside the call. 您可以在调用之外使用$app->url的参数。 It should be: 它应该是:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM