short_open_tag 문제 해결 방법


2018-11-02 09:32
31,796
1
0
본문
PHP Long Form
``` <?php ?> ```PHP Short Form
``` <? ?> ```
PHP Short Form을 사용가능하도록 만들어야 할 경우가 있습니다.
만약 Dedicated Server를 운용 중이라면, php.ini의 변수 중 short_open_tag를 찾아서 On으로 변경한 다음, php service를 재시작합니다.
``` short_open_tag = on ```
Apache 웹서버인 경우,
``` # /etc/init.d/apache2 restart ```혹은
``` # apache2ctl restart ```
nginx 웹서버인 경우,
``` # /etc/init.d/nginx restart ```혹은
``` # service nginx restart ```혹은
``` # nginx -s reload ```
만약 php.ini 파일에 대한 접근권한이 없는 경우, Document Root 디렉토리의 .htaccess 파일에 다음과 같은 코드를 삽입하고 저장합니다.
``` php_value short_open_tag 1 ```
php.ini 파일의 위치가 어디인지를 모를 경우, 다음과 같이 Terminal Interface에서 php --ini 명령을 실행한 후, Loaded Configuration File의 파일위치를 참고하면 됩니다.
``` # php --ini Configuration File (php.ini) Path: /etc/php/7.2/cli Loaded Configuration File: /etc/php/7.2/cli/php.ini Scan for additional .ini files in: /etc/php/7.2/cli/conf.d Additional .ini files parsed: /etc/php/7.2/cli/conf.d/10-mysqlnd.ini, /etc/php/7.2/cli/conf.d/10-opcache.ini, /etc/php/7.2/cli/conf.d/10-pdo.ini, /etc/php/7.2/cli/conf.d/15-xml.ini, /etc/php/7.2/cli/conf.d/20-bz2.ini, /etc/php/7.2/cli/conf.d/20-calendar.ini, /etc/php/7.2/cli/conf.d/20-ctype.ini, /etc/php/7.2/cli/conf.d/20-curl.ini, ```
short_open_tag에 관한 자세한 내용은 다음 링크를 참고하시기 바랍니다.
http://us1.php.net/manual/en/ini.core.php#ini.short-open-tag
0
로그인 후 추천 또는 비추천하실 수 있습니다.


포인트 210
경험치 989
[레벨 3] - 진행률
65%
가입일
2018-10-16 07:26:31
서명
미입력
자기소개
Web Application Programmer with PHP and ASP
- CodeIgniter, Laravel, Joomla, WordPress
- ASP/C# .NET, .NET Core
최신글이 없습니다.
최신글이 없습니다.
댓글목록1
JamesShin님의 댓글
PHP 5.4.0 버전 이전에는 short_open_tag를 On하지 않으면 <?=PHP변수명 혹은 PHP문장?>와 같은 형식, 예를 들어 <?=$_SERVER['DOCUMENT_ROOT'];?>와 같이 사용할 수 없고 반드시 <?php echo $_SERVER['DOCUMENT_ROOT']; ?>와 같이 사용하여야만 했습니다. 하지만, PHP 5.4.0 버전 이후로 short_open_tag의 On/Off와 무관하게 <?=PHP변수명 혹은 PHP문장?> 형식을 사용할 수 있습니다.