Alexander Starbuck
Alexander Starbuck

Reputation: 1159

Apache/Wamp/php issue? Chrome showing closing php tag ?>

I have a probably basic but still weird issue - Chrome won't show array properly and displays closing php tag. I'm sure i'm making some very basic error somewhere. I tried enclosing both array keys and values with single and double quotes, changing ending semicolon to colon, but nothing works.

Here is the test page code:

<html>
<head>
</head>

<body>
<?php

$beatles = array(
    "John" => "vocals",
    "Paul" => "bass",
    "George" => "guitar",
    "Ringo" => "drums",
);
?>

</body>
</html>

And here is the output in Chrome:

"vocals", "Paul" => "bass", "George" => "guitar", "Ringo" => "drums", ); ?>**

What am I doing wrong?

Upvotes: 0

Views: 106

Answers (5)

Hedi
Hedi

Reputation: 322

i think you save file with .html extension , and your file is not php file , you must write your code in file with php extension. and print_r your array for show array values.

Upvotes: 1

Mark
Mark

Reputation: 704

This code in a PHP file will show nothing, in html will not work. You should rename this file to fileName.php

Upvotes: 1

sunshinekitty
sunshinekitty

Reputation: 2375

First thing, make sure that you are accessing localhost and not the actual file on your computer. Your URL should say "localhost/yourfile.php".

Then, check and make sure that the file extension that you're loading ends in .php

Lastly, verify that Apache is setup to use PHP on .php files. You can verify this inside of the httpd.conf.

To do this,

  1. Left click on the Wamp icon in the bottom right tray of your computer
  2. Apache
  3. Left click httpd.conf
  4. Search for <IfModule mime_module>
  5. Verify that it has this line: AddType application/x-httpd-php .php

Upvotes: 1

Are you sure PHP is working on your server? Have you tested something else? Try the below given code and and see what happens?

<?php echo time(); ?>

Upvotes: 1

Utkarsh Dixit
Utkarsh Dixit

Reputation: 4275

There can be only one thing i am getting in mind and that is the extension of the file is not php. Check the extension of the file , if it's not php try to save the code into php.

Upvotes: 0

Related Questions