aliensbrain
  • Home
  • Study
  • Quizzes
  • 🎤AI Practicefree
  • Notebooks
  • Community
  • Sign in
  • Perl and Struts Framework Programming Quiz
  • If $string contains abcdefgh , what will the following ca...
Multiple choice technology programming languages

If $string contains abcdefgh , what will the following call return?

  1. substr($string, -2, 2);
  2. abc

  3. efgh

  4. gh

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The substr function call with a negative offset counts back from the end of the string. A start index of -2 extracts the last two characters of the string abcdefgh, which are g and h.

Keep practicing — related questions

  • If $string contains abcdefghijiklmdef , what will the following call return? rindex($string , "def", 11 );
  • If $string contains abcdefghijiklmdef , what will the following call return? rindex($string , "def", 11 );
  • If $string contains abcdabcd , what will the following call return? index ($string, “cd”, 3);
  • If $string contains abcdabcd , what will the following call return? index ($string, “cd”, 3);
  • $string = "Hello World"; substr($string,6)="Perl"; print $string;
  • What is the returned value for the following expression : string_substring("sachintendulkar", 3, 4)
  • What will be the result of this statement $SUBSTR(’ACCOUNT’, -3, 5) statement ?
  • $string = "good food"; $string =~ s/o*/e/;print $string;
Play the full quiz 🎤 Practise this topic out loud
Advertisement
© Aliensbrain | all rights reserved
  • About
  • Contact
  • Terms and Condition
  • Privacy Policy