質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

Q&A

解決済

1回答

1182閲覧

Parse error: syntax error, unexpected '[', expecting ')' in につて教えてください。

AtsushiFujita

総合スコア11

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

0グッド

0クリップ

投稿2016/10/11 13:19

編集2016/10/11 14:10

ワードプレスの更新中にこのようなメッセージがでてサイトへアクセスが出来なくなりました。

現在のバージョンはPHP5.3.3

###発生している問題・エラーメッセージ
Parse error: syntax error, unexpected '[', expecting ')' in /home//.com/public_html/ppc/wp-content/plugins/timeline-express/lib/classes/usage-tracking/vendor/keen-io/keen-io/src/Client/Resources/keen-io-3_0.php on line 129

###該当のソースコード

<?php return array( 'name' => 'KeenIO', 'apiVersion' => '3.0', 'operations' => array( 'getResources' => array( 'uri' => '/', 'description' => 'Returns the available child resources. Currently, the only child resource is the Projects Resource.', 'httpMethod' => 'GET', 'parameters' => array( 'masterKey' => array( 'location' => 'header', 'description' => 'The Master Api Key', 'sentAs' => 'Authorization', 'pattern' => '/^([[:alnum:]])+$/', 'type' => 'string', 'required' => true, ), ), ), 'createProject' => array( 'uri' => 'organizations/{organizationId}/projects', 'description' => 'Creates a project for the specified organization and returns the project id for later usage.', 'httpMethod' => 'POST', 'parameters' => array( 'organizationKey' => array( 'location' => 'header', 'description' => 'The Organization Key.', 'sentAs' => 'Authorization', 'pattern' => '/^([[:alnum:]])+$/', 'type' => 'string', 'required' => true, ), 'project_data' => array( 'location' => 'body', 'type' => 'array', 'filters' => array('json_encode'), ), ), ), 'getProjects' => array( 'uri' => 'projects', 'description' => 'Returns the projects accessible to the API user, as well as links to project sub-resources for discovery.', 'httpMethod' => 'GET', 'parameters' => array( 'masterKey' => array( 'location' => 'header', 'description' => 'The Master API Key.', 'sentAs' => 'Authorization', 'pattern' => '/^([[:alnum:]])+$/', 'type' => 'string', 'required' => true, ), ), ), 'getProject' => array( 'uri' => 'projects/{projectId}', 'description' => 'GET returns detailed information about the specific project, as well as links to related resources.', 'httpMethod' => 'GET', 'parameters' => array( 'masterKey' => array( 'location' => 'header', 'description' => 'The Master API Key.', 'sentAs' => 'Authorization', 'pattern' => '/^([[:alnum:]])+$/', 'type' => 'string', 'required' => true, ), ), ), 'getSavedQueries' => array( 'uri' => 'projects/{projectId}/queries/saved', 'description' => 'Returns the saved queries accessible to the API user on the specified project.', 'httpMethod' => 'GET', 'parameters' => array( 'masterKey' => array( 'location' => 'header', 'description' => 'The Master API Key.', 'sentAs' => 'Authorization', 'pattern' => '/^([[:alnum:]])+$/', 'type' => 'string', 'required' => true, ), ), ), 'getSavedQuery' => array( 'uri' => 'projects/{projectId}/queries/saved/{query_name}', 'description' => 'Returns the detailed information about the specified query, as well as links to retrieve results.', 'httpMethod' => 'GET', 'parameters' => array( 'masterKey' => array( 'location' => 'header', 'description' => 'The Master API Key.', 'sentAs' => 'Authorization', 'pattern' => '/^([[:alnum:]])+$/', 'type' => 'string', 'required' => true, ), 'query_name' => array( 'location' => 'uri', 'description' => 'The saved query.', 'required' => true, ), ), ), 'createSavedQuery' => array( 'uri' => 'projects/{projectId}/queries/saved/{query_name}', 'description' => 'Creates the described query.', 'httpMethod' => 'PUT', 'parameters' => array( 'masterKey' => array( 'location' => 'header', 'description' => 'The Master API Key.', 'sentAs' => 'Authorization', 'pattern' => '/^([[:alnum:]])+$/', 'type' => 'string', 'required' => true, ), 'query_name' => array( 'location' => 'uri', 'description' => 'The desired name of the query.', 'filters' => array(["method" => '\KeenIO\Client\KeenIOClient::cleanQueryName', "args" => ["@value"]]), 'required' => true, ),

###解決したいこと。
129行目は下記のようになります。
'filters' => array(["method" => '\KeenIO\Client\KeenIOClient::cleanQueryName', "args" => ["@value"]]),
どのようにコードをなおせばよいのでしょうか?

知識がないのでこのような質問で申し訳ございません。
説明不足があるようでしたらご了承ください。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

nnssn

2016/10/11 13:53

お使いのサーバーのPHPのバージョンは分かりますか?あと、本文中のPHPのコード(<?phpの行から最後の),の行あたりまで)を```の行ではさむと見やすい表示になるので、よければ編集をお願いします。
AtsushiFujita

2016/10/11 14:11

編集しました。これで宜しかったでしょうか?お手数おかけして申し訳ございません。
nnssn

2016/10/11 14:18

はい、問題ありません。ありがとうございます。
guest

回答1

0

ベストアンサー

メッセージ自体は予期しない位置に[があるという内容です。
PHP5.4からarray()[]と短く書けるようになったのですが、これをPHP5.3以下の環境で
動かすとこのような結果になってしまいます。

php

1["method" => '\KeenIO\Client\KeenIOClient::cleanQueryName', "args" => ["@value"]]

この部分ですね。PHP5.3向けに書き直すと

php

1array("method" => '\KeenIO\Client\KeenIOClient::cleanQueryName', "args" => ["@value"])

このようになります。ただ、ここを書き換えても他の箇所でも不具合が出る可能性が高そうです。
というのもtimeline-expressというプラグインが内部的に利用しているライブラリKeenIO
今回のエラーの発生元のようで、このライブラリの必須PHPバージョンを確認したところ5.6と
なっていました。少なくとも5.4~5.6固有の機能を全部洗い出して5.3向けに書き直す必要があるようです。

それよりは、可能ならばPHPの稼動バージョンを上げる(セキュリティー的にもこちらがベストです)、
timeline-expressの旧バージョンからPHP5.3でも動くものがないか探す、のほうが現実味があると思います。

KeenClient-PHP/keen-io-3_0.php at master · keenlabs/KeenClient-PHP
https://github.com/keenlabs/KeenClient-PHP/blob/master/src/Client/Resources/keen-io-3_0.php

投稿2016/10/11 14:34

nnssn

総合スコア1221

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

AtsushiFujita

2016/10/11 14:45

ご丁寧に対応して頂き誠に有難うございました。 バージョンをPHP5.6に変更するとログインできました。 とても勉強になり助かりました。 このサイトを知り良かったです。 お忙しい中本当に有難うございました。
nnssn

2016/10/11 14:53

5.6に対応しているサーバーだったんですね。それは話が早くてよかったです。 運営会社が新バージョンの導入に消極的だと、最悪引越しするしか手がないので...
AtsushiFujita

2016/10/11 14:56

そんなことがあるんですね。 今度からはサーバー名も記載して質問させて頂きます。 本当に助かりました!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問