qadenza
qadenza

Reputation: 9293

first occurrence of a variable has a value?

I downloaded some files from github (from this page, if matters ).

This is for php login stuff, and everything works, but I cannot understand how it is possible.

Here is the typical top part of my pages

require('inc/config.php'); // db credentials and connect
require('inc/password.php'); // class password, hashing etc
require('inc/user.php'); // class user

one of the first function in user.php is the following:

...
private function get_user_hash($username){  

    $_SESSION["uname"] = $username; // echo of this variable works
...

So, the question is - where the value of $username is coming from?

Because there is no such a variable in the preceding files (config.php and password.php).

This is its first occurrence in entire script workflow and how it is possible that it has some value?

Upvotes: 1

Views: 56

Answers (2)

ALOK
ALOK

Reputation: 553

find from where get_user_hash() is called and their will be some argument in it. It is not necessary that it should be named $username.
for ex-

  $user="some user name";
  get_user_hash($user);

Upvotes: 1

Dave Morrissey
Dave Morrissey

Reputation: 4411

$username is an argument of the get_user_hash function, which isn't executed until some code elsewhere in your script. Although it appears first, it isn't run first, and the code that calls this function will pass it a value for $username.

Upvotes: 1

Related Questions