Guest User

Untitled

a guest
Aug 15th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. Undefined offset in PHP
  2. function getusername($input){
  3. //parse the result
  4. preg_match("/<username>(.*)?</username>/", $input, $username);
  5. return $username[1]; // Line 4
  6. }
  7.  
  8. Undefined offset on line 4.
  9.  
  10. function getusername($input){
  11. preg_match("/<username>(.*)?</username>/", $input, $username);
  12. if( count( $username ) > 0 ) {
  13. return $username[1];
  14. }
  15. return false;
  16. }
  17.  
  18. function getusername($input){
  19. $matches = preg_match("/<username>(.*)?</username>/", $input, $username);
  20. if ($matches) {
  21. return $username[1];
  22. }
  23. return false;
  24. }
Add Comment
Please, Sign In to add comment