【PHP】構文の学習帳

公開日時:2018年02月25日 / 最終更新日時:2019年02月11日

PHPの基本的な構文をまとめています。

 

コメントアウトをしたい

■PHP構文内の場合

PHPプログラム内でのコメントアウトの方法です。

 

 

■html内の場合

 

 

デバッグをしたい(エラーメッセージを出力したい)

「/etc/php.ini」の設定をします。

最初に「/etc/php.ini」のバックアップを取ります。

[root@cent07 ~]# cp -ip /etc/php.ini /etc/php.ini_20180226

 

/etc/php.iniを編集して「display_errors = Off」をコメントアウトして「display_errors = On」を追加します。

[root@cent07 ~]# vi /etc/php.ini

 

~ 省略 ~

 

; This directive controls whether or not and where PHP will output errors,
; notices and warnings too. Error output is very useful during development, but
; it could be very dangerous in production environments. Depending on the code
; which is triggering the error, sensitive information could potentially leak
; out of your application such as database usernames and passwords or worse.
; It's recommended that errors be logged on production servers rather than
; having the errors sent to STDOUT.
; Possible Values:
;   Off = Do not display any errors
;   stderr = Display errors to STDERR (affects only CGI/CLI binaries!)
;   On or stdout = Display errors to STDOUT
; Default Value: On
; Development Value: On
; Production Value: Off
; http://php.net/display-errors
#display_errors = Off
display_errors = On

 

~ 省略 ~

 

/etc/php.ini を編集したら httpd を再起動します。

[root@cent07 ~]# systemctl restart httpd

 

以下のようにブラウザ上にエラーメッセージが出力されるようになりました。

 

Posted by 100%レンタルサーバーを使いこなすサイト管理人

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

AlphaOmega Captcha Medica  –  What Do You See?
     
 

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください

Secured By miniOrange