PHP Date |AND| Explode |AND| Find If String Contains a String
来源:互联网 发布:电力概预算软件 编辑:程序博客网 时间:2024/05/17 00:08
1.Date
<?php$date = date('m-d-y');$time = date('H:i:s');$day = date('l');echo ' the time is ' .$time;?>
2.Explode
<?php$sentence = 'I am zxl this is my php tutorial';$parts = explode(' ',$sentence); //分割字符串print_r($parts);?>
3.Find If String Contains a String(1)
<?php$sentence = 'I am zxl this is my php tutorial';$needle = 'z';$search = strpos($sentence , $needle);if ($search === FALES ){echo 'the string was not found';}else{echo 'the position of the string is ' . $search ;}?>
Find If String Contains a String(2)
<?php$email = 'zxl@gmail.com';$needle = '@';$search = strpos($email , $needle);if ($search === FALES ){echo 'this is not a valid email';}else{echo 'this is a valid email' ;}?>