Professional Documents
Culture Documents
Lec 27 (Validating User Input)
Lec 27 (Validating User 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()
Khizra Hanif, Department of Software
25
Engineering,LGU.
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);