Skip to content

Instantly share code, notes, and snippets.

@linkanp
Last active April 14, 2023 16:29
Show Gist options
  • Save linkanp/2eee9b066c1dde426bcac2547a7d286d to your computer and use it in GitHub Desktop.
Save linkanp/2eee9b066c1dde426bcac2547a7d286d to your computer and use it in GitHub Desktop.

PHP

  1. What will the following code block output?
for($i = 0; $i < 10; $i++){
    echo $i;
    if($i > 8){
      echo '!';
    } else {
      echo '';
    }
}

a. 012345678!9! b. 012345678!9!10 c. 0123456789! d. 0123456789!10! e. 12345678!9! f. 12345678!9!10! g. 123456789! h. 123456789!10!

  echo 'true';
}else {
  echo 'false';
}
class A{
  public function publicF(){
      echo 'A';
      $this->protectedF();
      $this->privateF();
    }
  protected function protectedF(){
      echo 'A';
    }
  private function privateF(){
      echo 'A';
    }
}

class B extends A{
  public function publicF(){
      echo 'B';
  parent::publicF();
    }
  protected function protectedF(){
   echo 'B';
  }
  private function privateF(){
      echo 'B';
    }
}
$b = new B();
$b::publicF();

BAAA BABB BABA (Correct) AAA ABB Other:

What can we pass to call_user_func function as a first argument? (provide all 4 correct answers) String containing name of the function (correct) String containing class and it's methods name, separated by "::" (correct) String containing object variable name and it's method name, separated by "->" String containing only method name, if we are calling this inside that object's body Array of two elements, where first element is object and second – it's method name as a string (correct) Array of functions Anonymous function (correct)

@Rainbow0420
Copy link

1-d. 0123456789!10!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment