Wamp not opening localhost on Windows 8 - php

Wamp is installed correctly and it works fine. However, when I try to open a file with Chrome (or any other) from the file explorer it opens the file with raw code: file:///C:/wamp/www/testing/built-in.php
But when I manually change the URL to localhost/tesing/built-in.php then the php code is executed fine.
So my question is: is there a way to open a PHP file in "localhost" instead of the "file:///" directly from the file explorer?

WAMP is a server, therefore the files can only be executed whilst being called from the server rather than from the local drive. When opening from the local drive, the file "by-passes" the server and it is directly displayed via the browser.

Related

PHP file isn't outputing to local browser, just showing code

Originally, I would select my php files and it would open the site on my local browser, I accidently opened it to notepad and now it will only open the code to editors. Does anyone know how to change the file setting back to when it would execute in the local browser? Ive tried resetting the filetype associations and resetting the file extension settings in the registry editor. I am currently using Windows 11
If you are not using a servlet like wamp or xampp you cannot process the php file on localhost.As long as the files have a php extension and are in the target folder of the servlet, while the servlet is active (example: if there is an index.php in the www folder in wamp. It will work if you type localhost/index.php in the browser.) your php files will work.

How could I preview a php file on the browser from a remote server?

I have a remote server on 'somedomain.cloudapp.azure.com' and I have a php file named on that server.
I would like to preview the 'index.php' file on browser to see the output. I used to open the files and edited it through terminal, but now I want to see the output of the php file.
I know from localhost I just put on the browser URL localhost and it preview the index.php, how to do that for a file that is on remote server?
You need multiple thing to see your result on the web page running on the own server ; like that web server such as engine nginx or apache , php-cli , if you using database you need phpMySql and there dependencies.

(weird) wamp server 2.5 just running localhost and phpmyadmin

I installed WAMP server 2.5 (not the first time. I installed on my other laptop which works fine).
It seems that WAMP is running fine because the WAMP icon turns green and I’m able to open localhost and PHPMyAdmin but, the problem occurs when I try to run other PHP files, the Chrome shows the PHP code as it is and IE downloads the file.
I can run index file from localhost but when I drag drop index file it doesn't work.
I can run index file from localhost but when I drag drop index file it
doesn't work.
Yes, this is expected behavior. Not just on WAMP but absolutely any local LAMP-based web development setup. Dragging and dropping a file like index.php won’t actually get the LAMP setup to parse the file.
PHP needs to be processed by an interpreter to get it run. Either from the command line or via a web server with a PHP interpreter setup as a module. When you drag and drop the file into a browser, that file never gets processed via the web server.
To get PHP processed and run it must simply be run via a URL connected to that local development server; such as the address http://localhost/index.php or http://localhost/ since an index.php should be automatically loaded by the web server as a directory index.

file_put_contents copying empty downloaded file on server but works well on localhost

Hi i need to copy a downloaded file from url to server for this i am using the
file_put_contents("down.csv", fopen("http://www.example.com.au", 'r'));
This is working fine on my localhost and copy the downloaded file content to down.csv but on live server it copes the empty file.
Please suggest what can be the issue.
There was a http:// wrapper is disabled in the server configuration by allow_url_fopen=0 now it is enabled on server and its working fine
thanks

Local PHP file won't open in Firefox

When I right click my local PHP file and select "open with Firefox" Firefox gets the focus for a second, but then the file opens in Dreamweaver instead. The same happens when I drag the file onto Firefox, or enter the URL ("file:///...") manually, or expressly select Firefox as the default application for PHP files. How can I get Firefox to show the file?
Firefox is not capable of handling PHP files, therefore it delegates their handling to a program that can do so (in your case, this is Dreamweaver).
PHP files should be served by a web server to the client (Firefox), which will display you the rendered content (probably HTML). PHP files are rendered by the PHP interpreter and then they are served using the HTTP protocol to a client as a web resource. So actually, you never open a PHP file with a browser, you just consume the HTTP resource that corresponds to the rendered output of that file.
Firefox can show .html-files. You have to install a webserver (xampp) to interprete .php-files. When xampp is installed, start xampp-control-panel, open your browser and (in case ur file is "test.php" in "c:\xampp\htdocs\test.php") and type http://localhost/test.php.
But first, right-click any php-file->Open with...->choose program, then select Firefox in the list.
You must install a local web server like xamp, wamp or easyphp.
Then you locate your files in that's www directory and see your file in browser with path:
localhost/myphp.php
Have a good time.
I have this solution to open a php on linux :
php -S localhost:8000
and open a firefox and go to the page :
http://localhost:8000/index.php
It works well for me.
The quickest way is to rename localhost/yourfile.php onto localhost/yourfile.html. (Tested on loop's Ubuntu 16.04 LTS)
You should deactivate adblock for localhost (or your domain), it should runs.
ABP icon -> click on deactivate on localhost -> F5

Categories