DOS formatted PHP files processed as plain text, other files processed normally. Why?

I've moved approximately 100 PHP files to a new LAMP server.  When the PHP files are called they are not processed, the code prints out as plain text.  If I create a new PHP file on the new server and copy/paste the code, it processes fine.  

When I open up the PHP files on the new server or the old server, with nano, I receive a notification "[  Read ## lines (Converted from DOS format).  ] "

What's going on here?  Why can't my new server handle these files?

New Server
RHEL6.5 Santiago - 64Bit
Apache 2.2.1
MySQL 5.1.73
PHP 5.3.3
ZergRushAsked:
Who is Participating?
 
savoneConnect With a Mentor Commented:
Try running the files through dos2unix.

http://linuxcommand.org/man_pages/dos2unix1.html

If you do not have dos2unix installed, just yum it.

yum -y install dos2unix
0
 
gr8gonzoConnect With a Mentor ConsultantCommented:
Check to see if your php files start with <? or <?php. If your new server doesn't have short tags enabled in the ini, then the first / shorter tag won't get treated as valid PHP.
0
 
Dave BaldwinFixer of ProblemsCommented:
What @gr8gonzo said is the most common cause of that problem.  I don't believe that the PHP interpreter cares about \n or \r\n line endings in the code.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
ZergRushAuthor Commented:
I've run the files through dos2unix. The converted files no longer display the "Converted from DOS format" notice in nano but are still printing as text.  The files I am testing with contain only "<?" and "?>".
0
 
Dave BaldwinFixer of ProblemsCommented:
"<?" is a 'short_open_tag'.  Try changing it to "<?php" and see if your files work.
0
 
ZergRushAuthor Commented:
My mistake, gr8gonzo was right, I read that wrong.  I'll change the ini.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.