webent Posted August 17, 2008 Share Posted August 17, 2008 Was wondering if anyone could point me in the right direction on how I would go about changing the calling location of images to their secure location after the page in which contains the images is called from a "require"? Here is my require... <? require $url . "/includes/header.inc"; ?> Now is there a way to parse that include file before it is output, to change any "<img src="http://" to "<img src="https://"? Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted August 17, 2008 Share Posted August 17, 2008 <?php $protocol = "http://"; if($protocol == "http://") { str_replace($protocol,"https://"); } ?> Quote Link to comment Share on other sites More sharing options...
webent Posted August 17, 2008 Author Share Posted August 17, 2008 Thank you MasterACE14 for your response... I know how to use str_replace() though, my problem is, parsing the include file before it is output... Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted August 17, 2008 Share Posted August 17, 2008 not sure what you mean. But maybe your after file_get_contents(); ? Quote Link to comment Share on other sites More sharing options...
webent Posted August 17, 2008 Author Share Posted August 17, 2008 Yeah, that might work, I'm not sure, I'll try it... Quote Link to comment Share on other sites More sharing options...
webent Posted August 17, 2008 Author Share Posted August 17, 2008 Ok, it worked, thanks MasterACE14... $completeFilePath = $preurl . "/includes/header.inc"; $handle = file_get_contents($completeFilePath); $search = array("<img src=\""); $replace = array("<img src=\"" . $otherurl . "/"); $fields = str_replace($search,$replace,$handle); echo $fields; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.