Guest User

Untitled

a guest
Dec 7th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. $mystring = "/var/www/html";
  2. $test = preg_match("/^/[.]/", $mystring);
  3.  
  4. if ($test == 1)
  5. {
  6. echo "ret = 1";
  7. }
  8. else
  9. {
  10. echo "ret = 0";
  11. }
  12.  
  13. <?php
  14. $mystring = "/var/www/html";
  15. $test = preg_match("/^//", $mystring);
  16.  
  17. if ($test == 1)
  18. {
  19. echo "ret = 1";
  20. }
  21. else
  22. {
  23. echo "ret = 0";
  24. }
  25.  
  26. <?php
  27. $mystring = "/var/www/html";
  28. if(strpos($mystring,"/") === 0){
  29. echo "ret = 1";
  30. }else{
  31. echo "ret = 0";
  32. }
  33. ?>
  34.  
  35. if (substr($mystring, 0, 1) == "/") {
  36. echo "ret= 1";
  37. }
  38.  
  39. echo $mystring[0] == "/" ? "ret 1" : "ret 0";
  40.  
  41. $mystring = "/var/www/html";
  42. $test = preg_match("/^//", $mystring);
  43.  
  44. if ($test == 1)
  45. {
  46. echo "ret = 1";
  47. }
  48. else
  49. {
  50. echo "ret = 0";
  51. }
Add Comment
Please, Sign In to add comment