Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #15406
| From | super70s <super70s@super70s.invalid> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: Syntax error help |
| Date | 2015-06-03 20:30 -0500 |
| Organization | albasani.net |
| Message-ID | <super70s-781AAC.20305303062015@reader.albasani.net> (permalink) |
| References | <super70s-8B1DCE.18194603062015@reader.albasani.net> <mko3kl$1sr$1@solani.org> |
In article <mko3kl$1sr$1@solani.org>, "Christoph M. Becker" <cmbecker69@arcor.de> wrote: > super70s wrote: > > > I'm getting a parse error (Parse error: syntax error, unexpected '[' in > > /home/sitename/public_html/videos/index.php on line 63) in the below > > YouTube video search script. > > > > I believe line 63 to be... > > $video = youtubeGetVideo($id)['snippet']; > > > > This error showed up after I moved this script to a different server. I > > think it might have something to do with the new server running a > > version of PHP earlier than 5.4. Either that or there's a bracket or > > semicolon that isn't closed, however it did work OK on the other server. > > > > If anyone has any idea what could be causing this and a fix I'd really > > appreciate it. > > Indeed, this syntax is available only as of PHP 5.4.0: "Function array > dereferencing has been added, e.g. foo()[0]."[1] For older versions > (which might better be avoided, because they are no longer supported), > you can get around the issue by assigning the function return value to > an auxiliary variable, and to access the desired element on that: > > $aux = youtubeGetVideo($id); > $video = $aux['snippet']; > > [1] <http://php.net/manual/en/migration54.new-features.php> That did it! Thank you very much Chris.
Back to comp.lang.php | Previous | Next — Previous in thread | Find similar | Unroll thread
Syntax error help super70s <super70s@super70s.invalid> - 2015-06-03 18:19 -0500
Re: Syntax error help "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-06-04 01:46 +0200
Re: Syntax error help super70s <super70s@super70s.invalid> - 2015-06-03 20:30 -0500
csiph-web