From the course: PHP for Web Designers
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
What on earth is T_ENCAPSED_AND_WHITESPACE? - PHP Tutorial
From the course: PHP for Web Designers
What on earth is T_ENCAPSED_AND_WHITESPACE?
This is one of the most enigmatic error messages you're likely to encounter in PHP. Fortunately, it's easy to deal with. Don't worry about this expecting identifier T_string or variable and all that. All you need to take notice of is this T in caps and white space and the line where it occurs. It's on line 19 so let's go to the editing program and look at it. And the problem is that this is a double quoted string and inside it is an associative array element. You can't do it just like that. You need to wrap the associative array element in a pair of curly braces, so curly brace before the dollar sign. Add a curly brace after the closing square bracket. Save the page. Go back to the browser. And the problem is sorted. The associative element is now displayed correctly. Just one little thing about that. Don't try to make your code look a little bit tidier by putting a space after that curly brace and a space at the end here. Let's just see what happens. Save the page. Reload the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Dealing with PHP errors4m 15s
-
Why is my page blank or incomplete?3m 53s
-
(Locked)
Tracking down parse errors4m 32s
-
(Locked)
What to do with "failed to open stream"3m 22s
-
(Locked)
What does "headers already sent" mean?6m 18s
-
(Locked)
What does undefined index, variable, or constant mean?5m 52s
-
(Locked)
What on earth is T_ENCAPSED_AND_WHITESPACE?1m 59s
-
(Locked)
-