Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which will execute first (PHP)?

Tags:

php

I have a function right here:

function loginForm($post){
    $username = c($post['username']);
    $password = md5(c($post['password']));
    if($this->login($username,$password))
        $this->setCookies($post);
}

As you can see the username and password are returned from a function called c() (which is just $mysqli->real_escape_string()).

Now, as you can see in the password field, there are 2 functions.

$password = md5(c($post['password']));

My question is, will the c() function run first, or the md5 function will run first? I'm almost sure the c() function is running first, but I'm not sure.

like image 795
Orel Biton Avatar asked Nov 24 '25 08:11

Orel Biton


2 Answers

c runs first.

Because you can rewrite it to:

$temp = c($post['password']);
$password = md5($temp);

You can not rewrite it so that md5 is called first.

like image 123
Halcyon Avatar answered Nov 26 '25 00:11

Halcyon


The c function will run first.

like image 33
tjfo Avatar answered Nov 25 '25 22:11

tjfo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!