0

Hello everyone! First of all thanks to all who helped in the past on my c++ problems, but now I need help with some php. I'm trying to search the beginning of a string for the http:// string but am having trouble with it. I can find the string inside the string but can't find it at the beginning of the string. In my attached code I wrapped a strpos() function inside of a substr() function and am trying to search the start of the string and stop the search after the http:// characters. I've tried changing the number of characters from 0 to 1 and 7 to 6 because strings start at 0 I suppose? Also, what about using JavaScript to check instead? although I'd rather use php. Any help would be greatly appreciated. Thank you!

$start = 0;
$end = 6;
$string = "http://";
if (substr(strpos($url, '$string'), '$start', '$end') === false ) {

die("Link must begin with http://");
}
1
Contributor
2
Replies
3
Views
6 Years
Discussion Span
Last Post by c++learner
0

By the way, just thought that I would tell you that I'm not getting any syntax errors with this code, it's just not working.

Hello everyone! First of all thanks to all who helped in the past on my c++ problems, but now I need help with some php. I'm trying to search the beginning of a string for the http:// string but am having trouble with it. I can find the string inside the string but can't find it at the beginning of the string. In my attached code I wrapped a strpos() function inside of a substr() function and am trying to search the start of the string and stop the search after the http:// characters. I've tried changing the number of characters from 0 to 1 and 7 to 6 because strings start at 0 I suppose? Also, what about using JavaScript to check instead? although I'd rather use php. Any help would be greatly appreciated. Thank you!

$start = 0;
$end = 6;
$string = "http://";
if (substr(strpos($url, '$string'), '$start', '$end') === false ) {

die("Link must begin with http://");
}
0

One more thing, I have to stop for now and won't be on until late tonight, so I'll check back then.
Thank you for your help.

Hello everyone! First of all thanks to all who helped in the past on my c++ problems, but now I need help with some php. I'm trying to search the beginning of a string for the http:// string but am having trouble with it. I can find the string inside the string but can't find it at the beginning of the string. In my attached code I wrapped a strpos() function inside of a substr() function and am trying to search the start of the string and stop the search after the http:// characters. I've tried changing the number of characters from 0 to 1 and 7 to 6 because strings start at 0 I suppose? Also, what about using JavaScript to check instead? although I'd rather use php. Any help would be greatly appreciated. Thank you!

$start = 0;
$end = 6;
$string = "http://";
if (substr(strpos($url, '$string'), '$start', '$end') === false ) {

die("Link must begin with http://");
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.