Notice: A non well formed numeric value encountered in /home/chonable/domains/chonable.com/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/chonable/domains/chonable.com/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Notice: A non well formed numeric value encountered in /home/chonable/domains/chonable.com/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/chonable/domains/chonable.com/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Notice: A non well formed numeric value encountered in /home/chonable/domains/chonable.com/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/chonable/domains/chonable.com/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Notice: A non well formed numeric value encountered in /home/chonable/domains/chonable.com/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/chonable/domains/chonable.com/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Notice: A non well formed numeric value encountered in /home/chonable/domains/chonable.com/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/chonable/domains/chonable.com/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Notice: A non well formed numeric value encountered in /home/chonable/domains/chonable.com/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/chonable/domains/chonable.com/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
พอดีว่าได้โหลด Visual studio Code มาใช้
ทีนี้โหลดพวก Extenstion ของ PHP มา VS Code มันก็แจ้งเตือนว่าต้องการ PHP7 นะ
แต่ตอนนี้เป็น PHP 5.6 (เนื่องจากว่าลง MAMP ไว้ก่อนแล้ว)
ลองไปเปลี่ยน PHP version ใน MAMP ก็ยังไม่หาย เพราะว่า มันเปลี่ยนเฉพาะใน MAMP มันไม่ได้เปลี่ยนค่า default ของ OS
ซึ่งต้องพิมพ์คำสั่งตรวจสอบ version ใน Termimal
1 |
php -v |
หมายเลข version ที่ได้จากคำสั่งนี้จะเป็น PHP ที่เป็น default ของ OS
การแก้ไข
เข้าไปที่ Terminal พิมพ์คำสั่ง
1 |
sudo nano ~/.bash_profile |
กรอกรหัสผ่านเสร็จ จะเป็นไฟล์เปล่าๆ ให้ใส่โค้ด
1 |
export PATH="/Applications/MAMP/bin/php/php7.0.15/bin:$PATH" |
กด ctrl + o แล้วกด enter เพื่อทำการบันทึก เสร็จแล้วอย่าลืมพิมพ์คำสั่ง
1 |
source ~/.bash_profile |
ที่นี้ลองพิมพ์
1 |
php -v |
ใน Terminal ดู จะได้หน้าตาประมาณนี้
1 2 3 |
PHP 7.0.15 (cli) (built: Jan 23 2017 15:06:38) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies |
ถ้า VS Code ยังแจ้งเตือนอยู่ ให้ Logout แล้ว Login ใหม่อีกครั้ง
ปล. ของผม MAMP Version 4.1.1 (492)