Lect 22 Validating Users Input
Lect 22 Validating Users Input
|^[0-9]{2}-[0-9]{2}-[0-9]{4}$|
Sub pattern Sub pattern Sub pattern
Start matching
Match the end of
from the start [0-9] {2} the string
Allowed length
characters
cnic
dob
Receiving values
Validating
name
CNIC
DoB
name
pass
pass1
Getting variables
Using strlen()
Password is short
Lowercase
uppercase
ucfirst()
ucwords()
Mubashir Ali - Lecturer (Department of
25
Computer Science).
3. String functions in PHP…
• strpos():
– finds the position of the first case-sensitive occurrence of a
substring in a string
– strpos($string,sub-string);
• strrpos():
– finds the position of the last case-sensitive occurrence of a
substring in a string
– strrpos($string,sub-string);
• substr_count():
– returns the number of times one string occurs within another
– substr_count($string,sub-string);