Tag: php

Questions Related to php

php
  1. print() can be used as part of an expression, while echo() can't

  2. echo() can be used as part of an expression, while print() can't

  3. echo() can be used in the CLI version of PHP, while print() can't

  4. print() can be used in the CLI version of PHP, while echo() can't


Correct Option: A
php
  1. $_10

  2. ${"MyVar"}

  3. &$something

  4. $10_somethings


Correct Option: D
php
  1. show_errors, enable

  2. show_errors, show

  3. register_globals, enhance

  4. register_globals, inject


Correct Option: D
php
  1. print substr($text, strchr($text, ':'));

  2. print substr($text, strchr($text, ':') 1);

  3. print substr($text, strpos($text, ':') 1);

  4. print substr($text, strpos($text, ':') 2);


Correct Option: D

Which of the following snippets prints a representation of 42 with two decimal places?

php
  1. printf("%.2d\n", 42);

  2. printf("%1.2f\n", 42);

  3. printf("%1.2u\n", 42);

  4. none of the above


Correct Option: B
php
  1. $a *= pow (2, 2);

  2. $a >>= 2;

  3. $a <<= 2;

  4. $a = $a $a;


Correct Option: A,C