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

If \$string contains abcdefgh , what will the following call return? substr(\$string, -2, 2);

  1. abc

  2. efgh

  3. gh

  4. None

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

The substr function extracts a substring starting at offset -2 (2nd character from the end: 'g') with length 2, returning 'gh'. Negative offsets count from the end of the string.

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 is the output of the following? substr (hiredate, - 2, 2) Given that hiredate is 01 Feb 13.
  • substr(string,position,) - returns pieces of a variable
Play the full quiz 🎤 Practise this topic out loud
Advertisement
© Aliensbrain | all rights reserved
  • About
  • Contact
  • Terms and Condition
  • Privacy Policy