I have a .php file in which i have a added a simple code:
<?php
header("Location:http//www.google.com");
?>
when i run this code, then instead of opening google.com it opens a download file, which is the same as my php file.
I have a .php file in which i have a added a simple code:
<?php
header("Location:http//www.google.com");
?>
when i run this code, then instead of opening google.com it opens a download file, which is the same as my php file.
You need to install/enable you server's php module, or if you are in windows, download WampServer and install it.
You have to make sure your server is setup to parse php files.
Something like this in apache:
AddHandler php5 .php .php5
edit
You would add this in the apache configuration file. httpd.conf
Take a look at this article. It walks you step by step on how to do this. I am assuming you are using windows.
You need a space after Location: for the redirect to work properly. Also, make sure you have the colon after http.
Try
header("Location: http://www.google.com");
Surely you meant
<?php header("Location: http://www.google.com"); ?>
?
The fact your server is sending you the file for download can have the meaning of the PHP not being enabled within, you have posted too little information for us to know what the real problems is.
The most common way to know the problem is by looking at a file that saves all the errors when you try to access your file, try looking into your log folder for a error_log file.
Is this a home server that you are trying to run your code with ? if so what are you using as a server ? apache, is php instelled and configured ? please provide as much information as you can, if you are hosting your site else where does your host have a Panel with errors log or can you see them on the ftp ?