Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. Metode 1
  2. <?php
  3. class profile() {
  4.     var $username;
  5.     var $andenVariabel;
  6.  
  7.     function setData($a,$b) {
  8.         $username = $a;
  9.         $andenVariabel = $b;
  10.     }
  11. }
  12.  
  13. $profil = new profile();
  14. $profil->setData("brugernavn","blabla");
  15.  
  16. echo $profil->username;
  17. echo $profil->andenVariabel;
  18. ?>
  19.  
  20. Metode 2 (min favorit)
  21. <?php
  22. class profile() {
  23.     var $username;
  24.     var $andenVariabel;
  25.  
  26.     function fetchUser($username) {
  27.         // NOGET DB STUFF DER HENTER BRUGEREN
  28.         $user = mysql.........;
  29.         $username = $user["username"];
  30.         $andenVariabel = $user["name"];
  31.     }
  32.  
  33.     function displayProfile() {
  34.         echo $this->username;
  35.         echo $this->andenVariabel;
  36.     }
  37. }
  38.  
  39. $profil = new profile();
  40. $profil->fetchUser("brugernavn");
  41. $profil->displayProfile();
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement