0

I'm reading through the drupal_bootstrap code at: https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_bootstrap/7 to try to understand how to bootstrap drupal code. I have experience in other languages but not php. This line of code below puzzles me, because $phases is an array, and everything else is int. What does it mean when it compares array with an int?

while ($phases && $phase > $stored_phase && $final_phase > $stored_phase) {
      $current_phase = array_shift($phases);

Thanks!

2
  • Also, I have a very basic question..what does it mean to bootstrap drupal code? Commented Jan 30, 2016 at 1:38
  • Welcome to Stack Overflow! If you do have another question, please do open another question. Commented Jan 30, 2016 at 1:46

2 Answers 2

2

In php basic comparison, an array with elements==True and an empty array==False.
array_shift() reduce the size of array.

So, in your example, the loop reduce the size of $phases until the $phases is empty.
(better: until $phases is empty or one of the other conditions are False)

Edit:

There is not a comparison between array and integer, the condition is:
ARRAY IS NOT EMPTY AND INT > INT AND INT > INT.

Edit 2:

Please note that there are a sort of incongruity in php type juggling comparison:

array() == False
''      == False
0       == False

but:

''      == 0
array() != ''   <------ !!!!
array() != 0    <------ !!!!
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! That's really helpful!
1

it does not compare array to int.
the first part of the condition where it uses $phases just checks that it has a value.

Definition of bootstrap in Computing:

a technique of loading a program into a computer by means of a few initial instructions which enable the introduction of the rest of the program from an input device.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.