3

Before everything happened, I was running this wordpress install for developing themes using xampp. But I decided to upgrade the memory of this machine from 2GB to 6GB since I need extra room for applications. I back-up my code in a separate partition by copying them. Since I have a 32bit OS at the time, I format the computer and installed a 64bit version. All is well and fine the OS side.

When I setup my web dev environment something goes wrong.

When I imported my htdocs back, first by just fully copying them to a new fresh install of xampp and notice that all of the codes that put are not working. My CI code is displaying my PHP code in the browser. My theme in wordpress is also commenting out my PHP code when I view the source. The themes included in my fresh wordpress install works so there's something I am missing here.

My Wordpress Theme when I activated it

My CodeIgniter Application when I browse it

From the looks of it, the php is being executed properly since anything that I install works. Just that the ones that came from a previous xampp is not.

Jocelyn
  • 11,209
  • 10
  • 43
  • 60
Mr A
  • 1,345
  • 4
  • 22
  • 51
  • 1
    Have you tried enabling the short tags in php.ini? From the first glance it looks like that could be a problem. – smottt Sep 24 '12 at 09:18
  • Open up the `php.ini` file and set `short_open_tag=On`. Then restart apache and check if it worked. – smottt Sep 24 '12 at 09:22
  • Also: http://stackoverflow.com/questions/200640/are-php-short-tags-acceptable-to-use – Terry Seidler Sep 24 '12 at 09:24
  • @smottt Thanks. It now works. Say, when I installed XAMPP this was left on by default. Why is it left out in the latest release? – Mr A Sep 24 '12 at 09:31
  • Perhaps because the use of short tags is discouraged: http://www.php.net/manual/en/language.basic-syntax.phptags.php – Terry Seidler Sep 24 '12 at 09:43
  • Might also be because the value changed in the bundled php.ini files from PHP 5.2 to PHP 5.3 from On to Off. – smottt Sep 24 '12 at 09:46
  • @MrA There is no need to edit the title and add "SOLVED". We know your issue is solved since you accepted an answer. – Jocelyn Oct 13 '12 at 15:33

3 Answers3

4

Open up the php.ini file and set short_open_tag = On. Then restart apache.

smottt
  • 3,272
  • 11
  • 37
  • 44
1

If you are opening a local script directly in the web browser, maybe through your editor, double-clicking on the file or dragging and dropping the file ito the browser - it will be treated as HTML only.

Instead, open the file by typing... http://localhost/your-file.php into the address bar. I personally create a projects folder in the htdocs folder and then create a bookmark for... http://localhost/projects/ and this will display all my projects that are saved into my projects folder.

Note: if you changed the mail port for the Apache server, you will need to add that to the path as well. eg. If your main port is 8888, your would do this... http://localhost:8080/your-file.php

I had the same problem and this worked for me. Good Luck

dms
  • 23
  • 4
0

For me, it was because the file was named as ".html". You must have an extension ".php"

cncDAni3
  • 53
  • 1
  • 8