1//php check if first four characters of a string = http
2substr( $http, 0, 4 ) === "http";
3//php check if first five characters of a string = https
4substr( $https, 0, 5 ) === "https";
5
1phpCopy<?php
2 $string = "Mr. Peter";
3 if(strncmp($string, "Mr.", 3) === 0){
4 echo "The string starts with the desired substring.";
5 }else
6 echo "The string does not start with the desired substring.";
7?>
8
1phpCopy<?php
2 $string = "Mr. Peter";
3 if(substr($string, 0, 3) === "Mr."){
4 echo "The string starts with the desired substring.";
5 }else
6 echo "The string does not start with the desired substring.";
7?>
8
1phpCopy<?php
2 $string = "Mr. Peter";
3 if(strpos( $string, "Mr." ) === 0){
4 echo "The string starts with the desired substring.";
5 }else
6 echo "The string does not start with the desired substring.";
7?>
8
1phpCopy<?php
2 $string = "mr. Peter";
3 if(strncasecmp($string, "Mr.", 3) === 0){
4 echo "The string starts with the desired substring.";
5 }else
6 echo "The string does not start with the desired substring.";
7?>
8