mrbuter Posted June 17, 2009 Share Posted June 17, 2009 This is so weird.... check out this function: function addhttp($url) { if (!strstr("http://", $url)) { $url = "http://".$url.""; } return $url; } It's so easy.... It's meant to add an http:// prefix to a url if it does not already have one. If I enter www.google.com into the function, it outputs as http://www.google.com (correct!0 If I enter http://www.google.com into the function, it outputs as http://http//www.google.com Two things here: 1. why is it adding the prefix if it already has it? The code shouldn't let that happen...right? 2. Stranger still, not only does it ADD the prefix, but it proceeds to remove the colon from the original http:// which results in http://http// rather than http://http:// (which would still be wrong anyways) Any ideas what on earth is going on?? Link to comment https://forums.phpfreaks.com/topic/162597-solved-super-simple-function-not-working-right/ Share on other sites More sharing options...
akitchin Posted June 17, 2009 Share Posted June 17, 2009 have a look at the manual for this function: strstr() you're mixing up your argument order. try switching them around and run it again, see what comes out. Link to comment https://forums.phpfreaks.com/topic/162597-solved-super-simple-function-not-working-right/#findComment-858156 Share on other sites More sharing options...
mrbuter Posted June 17, 2009 Author Share Posted June 17, 2009 I feel so silly Thanks Link to comment https://forums.phpfreaks.com/topic/162597-solved-super-simple-function-not-working-right/#findComment-858158 Share on other sites More sharing options...
akitchin Posted June 17, 2009 Share Posted June 17, 2009 no problem - please use the topic solved button when you've solved your issues in future. Link to comment https://forums.phpfreaks.com/topic/162597-solved-super-simple-function-not-working-right/#findComment-858160 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.