Reputation: 1159
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
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
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
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,
<IfModule mime_module>
AddType application/x-httpd-php .php
Upvotes: 1
Reputation: 64
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
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