Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. $commDocsAdminUsers
  2. $commDocsAdminExecutiveUsers
  3.  
  4. Warning: in_array() expects parameter 2 to be array, null given in - on line 25
  5.  
  6. <?php
  7. //ARRAYS OF USERS TO CHECK AGAINST
  8. $commDocsAdminUsers = array("kaisersolze", "bennyblanco", "carlitobrigante", "ashylarry", "claytonbigsby");
  9. $commDocsAdminExecutiveUsers = array("waltjr", "skylerwhite", "tuco", "skinnypete", "walterwhite");
  10.  
  11.  
  12.  
  13. class userLogin {
  14.  
  15.  
  16. // ALLOWS US TO SET THE NAME OF USER
  17. function set_name($new_name) {
  18. $this->name = $new_name;
  19. }
  20.  
  21. // ALLOWS US TO GET THE NAME OF USER
  22. function get_name() {
  23. return $this->name;
  24. }
  25.  
  26. // ALLOWS US TO CHECK THE ACCESS LEVEL OF THE USER... FIND WHICH ARRAY USER IS IN
  27. function check_access() {
  28. if (in_array("kaisersolze", $commDocsAdminUsers)){
  29. return "Match found in comDocsUsers Array";
  30. }
  31. else if (in_array($this->name, $commDocsAdminExecutiveUsers)){
  32. return "Match found in comDocsUsers Array";
  33. }
  34. else {
  35. return "No Access Allowed"; // USER NOT FOUND IN EITHER ARRAY
  36. }
  37. }
  38. }
  39.  
  40. // NOW LETS DO SOME STUFF WITH OUR NEW CLASS
  41. $currentUser = new userLogin(); // INVOKE THE NEW USER CLASS
  42. $currentUser->set_name("kaisersolze"); // SET NAME OF CURRENT USER
  43.  
  44. print_r($currentUser); // SHOW THE FULL OBJECT $CURRENTUSER
  45. echo '<BR>-------------------------------------------------------------<BR>';
  46. echo $currentUser->get_name(); // ECHO OUT THE NAME FOR THE $CURRENTUSER
  47. echo '<BR>--------------------------------------------------------------<BR>';
  48. echo $currentUser->check_access(); // CHECK TO SEE WHICH ARRAY THE USER IS IN
  49.  
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement