webkidd Posted October 19, 2006 Share Posted October 19, 2006 I just started a new server. My old server had no problem if scripts had <? instead of <?php. Now my server will not parse them and the page comes up blank. What do I need to do?- Steve Quote Link to comment Share on other sites More sharing options...
sanfly Posted October 19, 2006 Share Posted October 19, 2006 Do you have access to the php.ini file?[url=http://php.net/ini.core]http://php.net/ini.core[/url] Quote Link to comment Share on other sites More sharing options...
BrandonK Posted October 19, 2006 Share Posted October 19, 2006 <? ?> is using short tags which can be disabled by default in newer versions of PHP. Quote Link to comment Share on other sites More sharing options...
webkidd Posted October 19, 2006 Author Share Posted October 19, 2006 Yes I can edit the php.ini.How do I turn it back on? Quote Link to comment Share on other sites More sharing options...
sanfly Posted October 19, 2006 Share Posted October 19, 2006 Firstly, always back up your php.ini file before you make any changesTry searching for short_open_tag and see what value it is set to (0 or 1). From the information in the link I gave you, I would assume that 0 is off and 1 is on? Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted October 19, 2006 Share Posted October 19, 2006 It's best to alway's just code with <?phpLook throughout each page with search and replace.Or find and replace.<?with <?phpor just do it with php itself using str_replace()It's not good practice getting in that habit, as you can see, you will encounter problems. Quote Link to comment Share on other sites More sharing options...
Jenk Posted October 19, 2006 Share Posted October 19, 2006 Easier and future proof:open the file in notepad:ctrl+hreplace <?with <?phpctrl+hreplace: phpphpwith: phpIf it's loads of files.. won't be hard to write a small replace script:[code]<?phpfunction replaceTags($dir, $ext){ if (!$dir = realpath($dir)) return false; $hand = opendir($dir); while(($item = readdir($hand)) !== false) { $path = realpath($dir . DIRECTORY_SEPARATOR . $item); if (!in_array($item, array('.', '..'))) { if (!is_readable($path)) continue; if (is_dir($path)) { replaceTags($path, $ext); } elseif (strtolower(substr($path, -strlen($ext))) == strtolower($ext)) { $content = file_get_contents($content); $content = preg_replace( array('/<?\s{1}/', '/<?=/'), array('<?php ', '<?php echo '), $content ); file_put_contents($path, $content); } } } closedir($hand);}replaceTags('/var/www/doc_root', '.php');?>[/code]untested Quote Link to comment Share on other sites More sharing options...
webkidd Posted October 20, 2006 Author Share Posted October 20, 2006 Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.