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://");
}

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://");
}

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://");
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.