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

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

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

WordPressは、PHPで開発されているオープンソースのブログソフトウェアです。データベース管理システムにはMySQLを用いています。フリーのブログソフトウェアの中では最も人気が高く、PHPとHTMLを使って簡単にテンプレートをカスタマイズすることができます。

PHP

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

Q&A

解決済

3回答

2318閲覧

Parse error: syntax error, unexpected ';', expecting ')'

退会済みユーザー

退会済みユーザー

総合スコア0

WordPress

WordPressは、PHPで開発されているオープンソースのブログソフトウェアです。データベース管理システムにはMySQLを用いています。フリーのブログソフトウェアの中では最も人気が高く、PHPとHTMLを使って簡単にテンプレートをカスタマイズすることができます。

PHP

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

0グッド

0クリップ

投稿2016/05/04 03:38

編集2016/05/04 04:08

SEO用のキーワード変更WordpressPluginを作っています。
以下のエラーメッセージが発生しました。
どうすればいいですか

###発生している問題・エラーメッセージ

Parse error: syntax error, unexpected ';', expecting ')' in xxx/wp-content/plugins/KeywordsChenge/Plugin.php on line 50

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

PHP

1<?php 2/* 3Plugin Name: KeywordsChenge 4Plugin URI: 5Description: Change the search keyword in the web page. 6Version: 1.0 7Author: mk 8Author URI: 9License: GPL2 10*/ 11/* Copyright 2016 mk (email : yamk4054@gmail.com) 12 13 This program is free software; you can redistribute it and/or modify 14 it under the terms of the GNU General Public License, version 2, as 15 published by the Free Software Foundation. 16 17 This program is distributed in the hope that it will be useful, 18 but WITHOUT ANY WARRANTY; without even the implied warranty of 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 GNU General Public License for more details. 21 22 You should have received a copy of the GNU General Public License 23 along with this program; if not, write to the Free Software 24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 25*/ 26//lang 27 $mk_kc_lang_title = "キーワード管理"; 28 $mk_kc_lang_screen_title = "キーワード管理画面"; 29 $mk_kc_lang_keyword = "キーワード"; 30 $mk_kc_lang_save_messege = "変更を保存しました"; 31 $mk_kc_lang_save_button = "変更を保存"; 32//settings 33 $mk_kc_settings_maxkyes = 5; //Google of the recommended number of keywords,5 keywords. 34 35add_action( 'admin_menu', 'mk_kc_add_plugin_admin_menu' ); 36function 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');} 37function mk_kc_display_plugin_admin_page() { 38 if ( isset($_POST['mk_kc_options'])) {check_admin_referer('kcoptions');$opt = $_POST['mk_kc_options'];update_option('mk_kc_options', $opt); 39 ?> 40 <div class="updated fade"><p><strong><?php _e($mk_kc_lang_save_messege); ?></strong></p></div> 41 <?php 42 } 43 ?> 44 <div class="wrap"> 45 <div id="icon-options-general" class="icon32"><br /></div><h2><?php echo $mk_kc_lang_screen_title ?></h2> 46 <form action="" method="post"> 47 <?php 48 wp_nonce_field('kcoptions'); 49 $opt = get_option('mk_kc_options'); 50 for ($mk_kc_system_i = 1;$mk_kc_system_i < $mk_kc_settings_maxkyes;$mk_kc_system_i += 1;){ 51 $show_text[$mk_kc_system_i] = isset($opt['key'[$mk_kc_system_i]]) ? $opt['key'[$mk_kc_system_i]]: null; 52 } 53 ?> 54 <table class="form-table"> 55 <?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"} ?> 56 </table> 57 <p class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php echo $mk_kc_lang_save_button ?>" /></p> 58 </form> 59 <!-- /.wrap --></div> 60 <?php} 61//main 62function mk_kc_get_key($num) { 63 $opt = get_option('mk_kc_options'); 64 $array = $opt['text']; 65 $array[0] = ""; 66 if ($num == "List"){ 67 return implode(",",$array); 68 }elseif (is_int($num)){ 69 if{ 70 $array[$num] 71 }else{ 72 return ""; 73 } 74 }else{return "";} 75 76} 77?>

###補足情報(言語/FW/ツール等のバージョンなど)
PHP 7 wordpress最新

###追記
上のは解決したのですが今度は

コード

php

1<?php 2/* 3Plugin Name: KeywordsChenge 4Plugin URI: 5Description: Change the search keyword in the web page. 6Version: 1.0 7Author: mk 8Author URI: 9License: GPL2 10*/ 11/* Copyright 2016 mk (email : yamk4054@gmail.com) 12 13 This program is free software; you can redistribute it and/or modify 14 it under the terms of the GNU General Public License, version 2, as 15 published by the Free Software Foundation. 16 17 This program is distributed in the hope that it will be useful, 18 but WITHOUT ANY WARRANTY; without even the implied warranty of 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 GNU General Public License for more details. 21 22 You should have received a copy of the GNU General Public License 23 along with this program; if not, write to the Free Software 24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 25*/ 26//lang 27 $mk_kc_lang_title = "キーワード管理"; 28 $mk_kc_lang_screen_title = "キーワード管理画面"; 29 $mk_kc_lang_keyword = "キーワード"; 30 $mk_kc_lang_save_messege = "変更を保存しました"; 31 $mk_kc_lang_save_button = "変更を保存"; 32//settings 33 $mk_kc_settings_maxkyes = 5; //Google of the recommended number of keywords,5 keywords. 34 35add_action( 'admin_menu', 'mk_kc_add_plugin_admin_menu' ); 36function 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');} 37function mk_kc_display_plugin_admin_page() { 38 if ( isset($_POST['mk_kc_options'])) {check_admin_referer('kcoptions');$opt = $_POST['mk_kc_options'];update_option('mk_kc_options', $opt); 39 ?> 40 <div class="updated fade"><p><strong><?php _e($mk_kc_lang_save_messege); ?></strong></p></div> 41 <?php 42 } 43 ?> 44 <div class="wrap"> 45 <div id="icon-options-general" class="icon32"><br /></div><h2><?php echo $mk_kc_lang_screen_title ?></h2> 46 <form action="" method="post"> 47 <?php 48 wp_nonce_field('kcoptions'); 49 $opt = get_option('mk_kc_options'); 50 for ($mk_kc_system_i = 1;$mk_kc_system_i < $mk_kc_settings_maxkyes;$mk_kc_system_i += 1){ 51 $show_text[$mk_kc_system_i] = isset($opt['key'[$mk_kc_system_i]]) ? $opt['key'[$mk_kc_system_i]]: null; 52 } 53 ?> 54 <table class="form-table"> 55 <?php 56 for ($mk_kc_system_i = 1;$mk_kc_system_i < $mk_kc_settings_maxkyes;$mk_kc_system_i += 1){ 57 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"; 58 } 59 ?> 60 </table> 61 <p class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php echo $mk_kc_lang_save_button ?>" /></p> 62 </form> 63 <!-- /.wrap --></div> 64 <?php} 65//main 66function mk_kc_get_key($num) { 67 $opt = get_option('mk_kc_options'); 68 $array = $opt['text']; 69 $array[0] = ""; 70 if ($num == "List"){ 71 return implode(",",$array); 72 }elseif (is_int($num)){ 73 if{ 74 $array[$num] 75 }else{ 76 return ""; 77 } 78 }else{return "";} 79 80} 81?>
Parse error: syntax error, unexpected ';', expecting ')' in xxx/wp-content/plugins/KeywordsChenge/Plugin.php on line 56

上のエラーが出てしまいました

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

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

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

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

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

guest

回答3

0

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){

かな…

投稿2016/05/04 03:47

退会済みユーザー

退会済みユーザー

総合スコア0

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

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

退会済みユーザー

退会済みユーザー

2016/05/04 03:49

もう一つ for文に間違いありますね。
退会済みユーザー

退会済みユーザー

2016/05/04 03:56

wordpressにはよくある事ですね。wordpressって素敵です。
guest

0

結局こうなりました

PHP

1<?php 2/* 3Plugin Name: KeywordsChenge 4Plugin URI: 5Description: Change the search keyword in the web page. 6Version: 1.0 7Author: mk 8Author URI: 9License: GPL2 10*/ 11/* Copyright 2016 mk (email : yamk4054@gmail.com) 12 13 This program is free software; you can redistribute it and/or modify 14 it under the terms of the GNU General Public License, version 2, as 15 published by the Free Software Foundation. 16 17 This program is distributed in the hope that it will be useful, 18 but WITHOUT ANY WARRANTY; without even the implied warranty of 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 GNU General Public License for more details. 21 22 You should have received a copy of the GNU General Public License 23 along with this program; if not, write to the Free Software 24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 25*/ 26//lang 27 $mk_kc_lang_title = "キーワード管理"; 28 $mk_kc_lang_screen_title = "キーワード管理画面"; 29 $mk_kc_lang_keyword = "キーワード"; 30 $mk_kc_lang_save_messege = "変更を保存しました"; 31 $mk_kc_lang_save_button = "変更を保存"; 32//settings 33 $mk_kc_settings_maxkyes = 5; //Google of the recommended number of keywords,5 keywords. 34 35add_action( 'admin_menu', 'mk_kc_add_plugin_admin_menu' ); 36function 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');} 37function mk_kc_display_plugin_admin_page() { 38 if ( isset($_POST['mk_kc_options'])) {check_admin_referer('kcoptions');$opt = $_POST['mk_kc_options'];update_option('mk_kc_options', $opt); 39 ?> 40 <div class="updated fade"><p><strong><?php _e($mk_kc_lang_save_messege); ?></strong></p></div> 41 <?php 42 } 43 ?> 44 <div class="wrap"> 45 <div id="icon-options-general" class="icon32"><br /></div><h2><?php echo $mk_kc_lang_screen_title ?></h2> 46 <form action="" method="post"> 47 <?php 48 wp_nonce_field('kcoptions'); 49 $opt = get_option('mk_kc_options'); 50 for ($mk_kc_system_i = 1;$mk_kc_system_i < $mk_kc_settings_maxkyes;$mk_kc_system_i += 1){ 51 $show_text[$mk_kc_system_i] = isset($opt['key'[$mk_kc_system_i]]) ? $opt['key'[$mk_kc_system_i]]: null; 52 } 53 ?> 54 <table class="form-table"> 55 <?php 56 for ($mk_kc_system_i = 1;$mk_kc_system_i < $mk_kc_settings_maxkyes;$mk_kc_system_i += 1){ 57 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"; 58 } 59 ?> 60 </table> 61 <p class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php echo $mk_kc_lang_save_button ?>" /></p> 62 </form> 63 <!-- /.wrap --></div> 64 <?php 65} 66//main 67function mk_kc_get_key($num) { 68 $opt = get_option('mk_kc_options'); 69 $array = $opt['text']; 70 $array[0] = ""; 71 if ($num == "List"){return implode(",",$array);} 72 elseif (is_int($num)){return $array[$num];} 73 else{return "";} 74} 75?>

投稿2016/05/04 06:37

退会済みユーザー

退会済みユーザー

総合スコア0

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

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

0

ベストアンサー

とりあえず下記部分、PHP のコードとして変です。「&」はテキストとして連結するものではないです。

PHP

1echo "\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"; 2```また、luckerさんの回答で一度解決しているのであれば、追加で質問をするのではなく、新たに質問されるほうがよいです。そのほうがよりあなたの望まれる回答に出会える可能性が上がります。

投稿2016/05/04 05:47

kei344

総合スコア69407

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

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

退会済みユーザー

退会済みユーザー

2016/05/04 06:21

つい、VB系の癖で…
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問