简体   繁体   中英

Use PHP Include offline

In testing our site it would be so much easier to use PHP include offline. Essentially rather than put a page together for the purposes of testing, we would rather just include the various html files from their respective areas.

Our macs do not render PHP pages when offline and just show the source code. Is there a way to make them?

You need a local webserver in order to run php in your browser.

check out mamp or zend server

Once installed you can type localhost and whatever is the default directory will show in your browser. What I usually do is instad of just accessing everything through localhost I create an alias in the /private.etc/hosts/ file and the http.conf file in mamp

You would need a local web server to render any PHP code. MAMP might help you : www.mamp.info

To include HTML code into php with include() or require() you'll have to change the extension of the files from .html to .php even if no PHP code is inside them.

Also you could use a localhost server. There are mainly 2 of them for Mac:

  1. Mamp
  2. Xampp

I use the latter and I think it's the best. I had some trouble with Mamp years ago while Xampp worked just fine.

You have to make a php server. Free MAC php/ mysql server http://www.mamp.info/en/index.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM