Parse error: syntax error, unexpected ';', expecting ')'
- 評価
- クリップ 0
- VIEW 1,206

退会済みユーザー
SEO用のキーワード変更WordpressPluginを作っています。
以下のエラーメッセージが発生しました。
どうすればいいですか
発生している問題・エラーメッセージ
Parse error: syntax error, unexpected ';', expecting ')' in xxx/wp-content/plugins/KeywordsChenge/Plugin.php on line 50
該当のソースコード
<?php
/*
Plugin Name: KeywordsChenge
Plugin URI:
Description: Change the search keyword in the web page.
Version: 1.0
Author: mk
Author URI:
License: GPL2
*/
/* Copyright 2016 mk (email : yamk4054@gmail.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//lang
$mk_kc_lang_title = "キーワード管理";
$mk_kc_lang_screen_title = "キーワード管理画面";
$mk_kc_lang_keyword = "キーワード";
$mk_kc_lang_save_messege = "変更を保存しました";
$mk_kc_lang_save_button = "変更を保存";
//settings
$mk_kc_settings_maxkyes = 5; //Google of the recommended number of keywords,5 keywords.
add_action( 'admin_menu', 'mk_kc_add_plugin_admin_menu' );
function mk_kc_add_plugin_admin_menu() {add_options_page($mk_kc_lang_title,$mk_kc_lang_screen_title,'administrator', 'keywords','mk_kc_display_plugin_admin_page');}
function mk_kc_display_plugin_admin_page() {
if ( isset($_POST['mk_kc_options'])) {check_admin_referer('kcoptions');$opt = $_POST['mk_kc_options'];update_option('mk_kc_options', $opt);
?>
<div class="updated fade"><p><strong><?php _e($mk_kc_lang_save_messege); ?></strong></p></div>
<?php
}
?>
<div class="wrap">
<div id="icon-options-general" class="icon32"><br /></div><h2><?php echo $mk_kc_lang_screen_title ?></h2>
<form action="" method="post">
<?php
wp_nonce_field('kcoptions');
$opt = get_option('mk_kc_options');
for ($mk_kc_system_i = 1;$mk_kc_system_i < $mk_kc_settings_maxkyes;$mk_kc_system_i += 1;){
$show_text[$mk_kc_system_i] = isset($opt['key'[$mk_kc_system_i]]) ? $opt['key'[$mk_kc_system_i]]: null;
}
?>
<table class="form-table">
<?php for ($mk_kc_system_i = 1,$mk_kc_system_i < $mk_kc_settings_maxkyes,$mk_kc_system_i += 1;){echo "\t<tr valign=\"top\"><th scope=\"row\"><label for=\"inputtext\">" & $mk_kc_lang_keyword & "</label></th><td><input name=\"mk_kc_options[key["$mk_kc_system_i"]]\" type=\"key\" id=\"inputtext\" value=" & $show_text[$mk_kc_system_i] & " class=\"regular-text\" /></td></tr>\n\t\t\t"} ?>
</table>
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php echo $mk_kc_lang_save_button ?>" /></p>
</form>
<!-- /.wrap --></div>
<?php}
//main
function mk_kc_get_key($num) {
$opt = get_option('mk_kc_options');
$array = $opt['text'];
$array[0] = "";
if ($num == "List"){
return implode(",",$array);
}elseif (is_int($num)){
if{
$array[$num]
}else{
return "";
}
}else{return "";}
}
?>
補足情報(言語/FW/ツール等のバージョンなど)
PHP 7 wordpress最新
追記
上のは解決したのですが今度は
コード
<?php
/*
Plugin Name: KeywordsChenge
Plugin URI:
Description: Change the search keyword in the web page.
Version: 1.0
Author: mk
Author URI:
License: GPL2
*/
/* Copyright 2016 mk (email : yamk4054@gmail.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//lang
$mk_kc_lang_title = "キーワード管理";
$mk_kc_lang_screen_title = "キーワード管理画面";
$mk_kc_lang_keyword = "キーワード";
$mk_kc_lang_save_messege = "変更を保存しました";
$mk_kc_lang_save_button = "変更を保存";
//settings
$mk_kc_settings_maxkyes = 5; //Google of the recommended number of keywords,5 keywords.
add_action( 'admin_menu', 'mk_kc_add_plugin_admin_menu' );
function mk_kc_add_plugin_admin_menu() {add_options_page($mk_kc_lang_title,$mk_kc_lang_screen_title,'administrator', 'keywords','mk_kc_display_plugin_admin_page');}
function mk_kc_display_plugin_admin_page() {
if ( isset($_POST['mk_kc_options'])) {check_admin_referer('kcoptions');$opt = $_POST['mk_kc_options'];update_option('mk_kc_options', $opt);
?>
<div class="updated fade"><p><strong><?php _e($mk_kc_lang_save_messege); ?></strong></p></div>
<?php
}
?>
<div class="wrap">
<div id="icon-options-general" class="icon32"><br /></div><h2><?php echo $mk_kc_lang_screen_title ?></h2>
<form action="" method="post">
<?php
wp_nonce_field('kcoptions');
$opt = get_option('mk_kc_options');
for ($mk_kc_system_i = 1;$mk_kc_system_i < $mk_kc_settings_maxkyes;$mk_kc_system_i += 1){
$show_text[$mk_kc_system_i] = isset($opt['key'[$mk_kc_system_i]]) ? $opt['key'[$mk_kc_system_i]]: null;
}
?>
<table class="form-table">
<?php
for ($mk_kc_system_i = 1;$mk_kc_system_i < $mk_kc_settings_maxkyes;$mk_kc_system_i += 1){
echo "\t<tr valign=\"top\"><th scope=\"row\"><label for=\"inputtext\">" & $mk_kc_lang_keyword & "</label></th><td><input name=\"mk_kc_options[key["$mk_kc_system_i"]]\" type=\"key\" id=\"inputtext\" value=" & $show_text[$mk_kc_system_i] & " class=\"regular-text\" /></td></tr>\n\t\t\t";
}
?>
</table>
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php echo $mk_kc_lang_save_button ?>" /></p>
</form>
<!-- /.wrap --></div>
<?php}
//main
function mk_kc_get_key($num) {
$opt = get_option('mk_kc_options');
$array = $opt['text'];
$array[0] = "";
if ($num == "List"){
return implode(",",$array);
}elseif (is_int($num)){
if{
$array[$num]
}else{
return "";
}
}else{return "";}
}
?>
Parse error: syntax error, unexpected ';', expecting ')' in xxx/wp-content/plugins/KeywordsChenge/Plugin.php on line 56
上のエラーが出てしまいました
-
気になる質問をクリップする
クリップした質問は、後からいつでもマイページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
クリップを取り消します
-
良い質問の評価を上げる
以下のような質問は評価を上げましょう
- 質問内容が明確
- 自分も答えを知りたい
- 質問者以外のユーザにも役立つ
評価が高い質問は、TOPページの「注目」タブのフィードに表示されやすくなります。
質問の評価を上げたことを取り消します
-
評価を下げられる数の上限に達しました
評価を下げることができません
- 1日5回まで評価を下げられます
- 1日に1ユーザに対して2回まで評価を下げられます
質問の評価を下げる
teratailでは下記のような質問を「具体的に困っていることがない質問」、「サイトポリシーに違反する質問」と定義し、推奨していません。
- プログラミングに関係のない質問
- やってほしいことだけを記載した丸投げの質問
- 問題・課題が含まれていない質問
- 意図的に内容が抹消された質問
- 広告と受け取られるような投稿
評価が下がると、TOPページの「アクティブ」「注目」タブのフィードに表示されにくくなります。
質問の評価を下げたことを取り消します
この機能は開放されていません
評価を下げる条件を満たしてません
質問の評価を下げる機能の利用条件
この機能を利用するためには、以下の事項を行う必要があります。
- 質問回答など一定の行動
-
メールアドレスの認証
メールアドレスの認証
-
質問評価に関するヘルプページの閲覧
質問評価に関するヘルプページの閲覧
+1
for ($mk_kc_system_i = 1;$mk_kc_system_i < $mk_kc_settings_maxkyes;$mk_kc_system_i += 1;){
↓
for ($mk_kc_system_i = 1;$mk_kc_system_i < $mk_kc_settings_maxkyes;$mk_kc_system_i += 1){
かな…
投稿
-
回答の評価を上げる
以下のような回答は評価を上げましょう
- 正しい回答
- わかりやすい回答
- ためになる回答
評価が高い回答ほどページの上位に表示されます。
-
回答の評価を下げる
下記のような回答は推奨されていません。
- 間違っている回答
- 質問の回答になっていない投稿
- スパムや攻撃的な表現を用いた投稿
評価を下げる際はその理由を明確に伝え、適切な回答に修正してもらいましょう。
checkベストアンサー
0
とりあえず下記部分、PHP のコードとして変です。「&」はテキストとして連結するものではないです。
echo "\t<tr valign=\"top\"><th scope=\"row\"><label for=\"inputtext\">" & $mk_kc_lang_keyword & "</label></th><td><input name=\"mk_kc_options[key["$mk_kc_system_i"]]\" type=\"key\" id=\"inputtext\" value=" & $show_text[$mk_kc_system_i] & " class=\"regular-text\" /></td></tr>\n\t\t\t";
また、luckerさんの回答で一度解決しているのであれば、追加で質問をするのではなく、新たに質問されるほうがよいです。そのほうがよりあなたの望まれる回答に出会える可能性が上がります。
投稿
-
回答の評価を上げる
以下のような回答は評価を上げましょう
- 正しい回答
- わかりやすい回答
- ためになる回答
評価が高い回答ほどページの上位に表示されます。
-
回答の評価を下げる
下記のような回答は推奨されていません。
- 間違っている回答
- 質問の回答になっていない投稿
- スパムや攻撃的な表現を用いた投稿
評価を下げる際はその理由を明確に伝え、適切な回答に修正してもらいましょう。
0
結局こうなりました
<?php
/*
Plugin Name: KeywordsChenge
Plugin URI:
Description: Change the search keyword in the web page.
Version: 1.0
Author: mk
Author URI:
License: GPL2
*/
/* Copyright 2016 mk (email : yamk4054@gmail.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//lang
$mk_kc_lang_title = "キーワード管理";
$mk_kc_lang_screen_title = "キーワード管理画面";
$mk_kc_lang_keyword = "キーワード";
$mk_kc_lang_save_messege = "変更を保存しました";
$mk_kc_lang_save_button = "変更を保存";
//settings
$mk_kc_settings_maxkyes = 5; //Google of the recommended number of keywords,5 keywords.
add_action( 'admin_menu', 'mk_kc_add_plugin_admin_menu' );
function mk_kc_add_plugin_admin_menu() {add_options_page($mk_kc_lang_title,$mk_kc_lang_screen_title,'administrator', 'keywords','mk_kc_display_plugin_admin_page');}
function mk_kc_display_plugin_admin_page() {
if ( isset($_POST['mk_kc_options'])) {check_admin_referer('kcoptions');$opt = $_POST['mk_kc_options'];update_option('mk_kc_options', $opt);
?>
<div class="updated fade"><p><strong><?php _e($mk_kc_lang_save_messege); ?></strong></p></div>
<?php
}
?>
<div class="wrap">
<div id="icon-options-general" class="icon32"><br /></div><h2><?php echo $mk_kc_lang_screen_title ?></h2>
<form action="" method="post">
<?php
wp_nonce_field('kcoptions');
$opt = get_option('mk_kc_options');
for ($mk_kc_system_i = 1;$mk_kc_system_i < $mk_kc_settings_maxkyes;$mk_kc_system_i += 1){
$show_text[$mk_kc_system_i] = isset($opt['key'[$mk_kc_system_i]]) ? $opt['key'[$mk_kc_system_i]]: null;
}
?>
<table class="form-table">
<?php
for ($mk_kc_system_i = 1;$mk_kc_system_i < $mk_kc_settings_maxkyes;$mk_kc_system_i += 1){
echo "\t<tr valign=\"top\"><th scope=\"row\"><label for=\"inputtext\">" . $mk_kc_lang_keyword . "</label></th><td><input name=\"mk_kc_options[key[" . $mk_kc_system_i . "]]\" type=\"key\" id=\"inputtext\" value=" . $show_text[$mk_kc_system_i] . " class=\"regular-text\" /></td></tr>\n\t\t\t";
}
?>
</table>
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php echo $mk_kc_lang_save_button ?>" /></p>
</form>
<!-- /.wrap --></div>
<?php
}
//main
function mk_kc_get_key($num) {
$opt = get_option('mk_kc_options');
$array = $opt['text'];
$array[0] = "";
if ($num == "List"){return implode(",",$array);}
elseif (is_int($num)){return $array[$num];}
else{return "";}
}
?>
投稿
-
回答の評価を上げる
以下のような回答は評価を上げましょう
- 正しい回答
- わかりやすい回答
- ためになる回答
評価が高い回答ほどページの上位に表示されます。
-
回答の評価を下げる
下記のような回答は推奨されていません。
- 間違っている回答
- 質問の回答になっていない投稿
- スパムや攻撃的な表現を用いた投稿
評価を下げる際はその理由を明確に伝え、適切な回答に修正してもらいましょう。
15分調べてもわからないことは、teratailで質問しよう!
- ただいまの回答率 89.98%
- 質問をまとめることで、思考を整理して素早く解決
- テンプレート機能で、簡単に質問をまとめられる
2016/05/04 12:49
2016/05/04 12:56