Vinny
Vinny

Reputation: 151

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.

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.

Upvotes: 0

Views: 60

Answers (1)

Barmar
Barmar

Reputation: 782310

You messed up the way you're calling the url method when you added the call to str_replace; you have the argument to $app->url outside the call. It should be:

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

Upvotes: 2

Related Questions