Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Zend 200-710 Exam - Topic 2 Question 76 Discussion

Actual exam question for Zend's 200-710 exam
Question #: 76
Topic #: 2
[All 200-710 Questions]

You want to access the 3rd character of a string, contained in the variable $test. Which of the following possibilites work? (Choose 2)

Show Suggested Answer Hide Answer
Suggested Answer: B, D

Contribute your Thoughts:

0/2000 characters
Marsha
4 months ago
Surprised that $test{2} still works, isn't that outdated?
upvoted 0 times
...
Carmela
4 months ago
I thought you had to start counting from 1, not 0.
upvoted 0 times
...
Catalina
4 months ago
Wait, why is $test(3) even an option? That's just wrong.
upvoted 0 times
...
Samira
5 months ago
Totally agree, those are the correct ones!
upvoted 0 times
...
Herman
5 months ago
You can use $test[2] and $test{2} for the 3rd character.
upvoted 0 times
...
Kallie
5 months ago
I’m pretty sure B and D are the right answers, but I’m a bit confused about the curly braces.
upvoted 0 times
...
Shayne
5 months ago
I feel like option A is definitely wrong, but I can't recall if D is still acceptable.
upvoted 0 times
...
Leana
5 months ago
I think I practiced something similar, but I’m not sure if using curly braces is still valid in newer PHP versions.
upvoted 0 times
...
Leslie
6 months ago
I remember that string indexing starts at 0, so the 3rd character should be at index 2.
upvoted 0 times
...
Deonna
6 months ago
Hmm, the curly brace syntax $test{3} is throwing me off. I don't think I've seen that before, so I'll skip that one and focus on the more familiar array/parentheses options.
upvoted 0 times
...
Silvana
6 months ago
I've got a good feeling about the $test[2] option. That's how I usually access individual characters in a string, so I'll go with that.
upvoted 0 times
...
Johnathon
6 months ago
Wait, is it zero-indexed or one-indexed? I'm a bit confused on that. Maybe I should try both the (2) and [2] options just to be sure.
upvoted 0 times
...
Osvaldo
6 months ago
Okay, let me see... I think the array syntax $test[2] should work, since array indices start at 0. I'll try that one.
upvoted 0 times
...
Lanie
6 months ago
Hmm, this looks like a tricky one. I'll need to think carefully about the syntax for accessing characters in a string.
upvoted 0 times
...
Cyril
1 year ago
Option B is the way to go. Accessing array elements using square brackets is the most straightforward and intuitive approach.
upvoted 0 times
Sheridan
1 year ago
User1: Great, thanks for confirming!
upvoted 0 times
...
Matthew
1 year ago
Yes, I agree. That's the correct way to access the 3rd character of a string.
upvoted 0 times
...
Marica
1 year ago
I think option B) echo $test[2]; is correct.
upvoted 0 times
...
...
Kimberlie
1 year ago
I'm not sure about option D) echo $test{2}. I think curly braces {} are used for variables, not string characters.
upvoted 0 times
...
Rhea
1 year ago
Haha, this is a classic PHP gotcha! I remember wasting an embarrassing amount of time on this exact question during my last interview.
upvoted 0 times
Hildred
1 year ago
D) echo $test{2};
upvoted 0 times
...
Brandon
1 year ago
B) echo $test[2];
upvoted 0 times
...
...
Sheridan
2 years ago
I agree with Kristeen. Using square brackets [] is the correct way to access characters in a string.
upvoted 0 times
...
Afton
2 years ago
D looks like the most logical choice to me. Who uses those weird parentheses anyway? Team curly braces all the way!
upvoted 0 times
Goldie
1 year ago
I always use curly braces for accessing characters in a string. E) echo $test{3}; is the way to go.
upvoted 0 times
...
Stephaine
1 year ago
Actually, D) echo $test{2}; is the correct syntax for accessing the 3rd character.
upvoted 0 times
...
Myong
2 years ago
I agree, B) echo $test[2]; is the correct way to access the 3rd character.
upvoted 0 times
...
Belen
2 years ago
I think B) echo $test[2]; would work too.
upvoted 0 times
...
...
Kristeen
2 years ago
I think the correct options are B) echo $test[2] and E) echo $test{3}
upvoted 0 times
...
Lauran
2 years ago
I was sure that A and C were the right answers. Guess I need to brush up on my PHP string manipulation skills.
upvoted 0 times
...
Ramonita
2 years ago
B and D are the correct options. Arrays in PHP are zero-indexed, so the 3rd character is at index 2.
upvoted 0 times
Tegan
1 year ago
D) echo $test{2};
upvoted 0 times
...
Tegan
2 years ago
B) echo $test[2];
upvoted 0 times
...
...

Save Cancel