Home Backend Development PHP Tutorial 说一个很多菜鸟(例如小弟我)都遇到的有关问题的解决办法,当然这个解决办法却引出另一个有关问题,求解!

说一个很多菜鸟(例如小弟我)都遇到的有关问题的解决办法,当然这个解决办法却引出另一个有关问题,求解!

Jun 13, 2016 am 10:34 AM
apache html localhost php

说一个很多初学者(例如我)都遇到的问题的解决方法,当然这个解决方法却引出另一个问题,求解!!
大家(超级初学者们),是不是都试过php不能解析,也就是用浏览器打开的php文件,里面的html内容可以正常解析显示出来,但是php的代码却只能当成是源代码显示出来,即使你已经经过了常人所不能忍受的调试以及apache的连夜配置,也都失败,那就在你即将放弃的时候,我(刚刚连夜弄个一共20个小时还是失败的超级小白),告诉你吧(刚刚和我一起奋战研究的同学终于搞出来了),其实:我们需要把我们的php放在apache的默认目录(比如我的linux就是/var/www/html里面)下,就能被正常解析,赶紧试试吧!!


PS:因为我是刚刚知道太过激动才忍不住上来分享了的,没有去看论坛有没有相同的解决方法,也没有看有没有人遇到这个问题(如果没有人遇到这个弱智问题,我就尴尬了…………),所以不知到的同学尽管拿去,知道的高手们也不要笑我,呵呵



另外,问题来了,据我所知,好像只有我,和我的同学必须得 “ 把我们的php放在apache的默认目录 ”才能解析,网上其他人都是不需要的,所以说其实我这个所谓的解决方法只是另外一个没有那么严重的问题而已~~~所以在这求助大家,怎么办啊~~我想在电脑的其它地方也能进行php编程啊……………………~~~~!!!!

------解决方案--------------------
去网上搜“配置apache虚拟主机”看看。
------解决方案--------------------
印象里好像有1/500的机会出现你说的事情.

如果出现显示源码的话基本上可以肯定是apache 没有给他解析这个后缀.php的配置信息
如果出现下载文件的话基本上可以肯定的是php没有正常的安装.

如果出现只能在默认目录才能看到文件的话,那你的apache配置应该没有正确的设置根目录位置...

挺多的.不过其实也就那么点事.如果你只是初学为了php 暂时不要在这里纠结,先下个xampp安装了去吧.
有很多公司你去的时候这些都是已经完善了的,你只需要了解目录结构,会ftp就完事了.后期的话你可以自己去学一学
还有vcs.
------解决方案--------------------
输出phpinfo 看看你的phpinfo是否能够正常的解析.如果可以的话那么就要考虑你是不是写了短标签.
如果不行那就还是要回去调试apache.

探讨

引用:

印象里好像有1/500的机会出现你说的事情.

如果出现显示源码的话基本上可以肯定是apache 没有给他解析这个后缀.php的配置信息
如果出现下载文件的话基本上可以肯定的是php没有正常的安装.

如果出现只能在默认目录才能看到文件的话,那你的apache配置应该没有正确的设置根目录位置...

挺多的.不过其实也就那么点事.如果你只是初学为了p……

------解决方案--------------------
必须要以“主机名”来访问才能被apache解析。localhost 就代表本机。
------解决方案--------------------
我前几天也遇到同样的情况,lz说的是一种,但是要是单单浏览页面的话,也可以把.php文件改成.html的,可以放到电脑的其它位置正常浏览,不会只显示源代码
------解决方案--------------------
你重心放错地方了,你的重心应该是如何运用PHP,而不是配置PHP环境,就像你用电脑,但不一定需要知道电脑的运行机制的。配置运行环境你只需要大概了解就行,不需要太深入。以后弄PHP,直接用集成安装包弄就行了。
------解决方案--------------------
这应该是个常识吧,不放在解析目录里,当然不会被解析,当然,这个目录不一定是固定的,也可以设置的
------解决方案--------------------
探讨

引用:

你重心放错地方了,你的重心应该是如何运用PHP,而不是配置PHP环境,就像你用电脑,但不一定需要知道电脑的运行机制的。配置运行环境你只需要大概了解就行,不需要太深入。以后弄PHP,直接用集成安装包弄就行了。


我现在也有这种感觉,干脆我就在localhost练习算了,不追求方便了,反正到时搭载服务器之后外界是一定会通过web服务器进行解析php的,应该不……
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1669
14
PHP Tutorial
1273
29
C# Tutorial
1256
24
HTML vs. CSS and JavaScript: Comparing Web Technologies HTML vs. CSS and JavaScript: Comparing Web Technologies Apr 23, 2025 am 12:05 AM

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

The Compatibility of IIS and PHP: A Deep Dive The Compatibility of IIS and PHP: A Deep Dive Apr 22, 2025 am 12:01 AM

IIS and PHP are compatible and are implemented through FastCGI. 1.IIS forwards the .php file request to the FastCGI module through the configuration file. 2. The FastCGI module starts the PHP process to process requests to improve performance and stability. 3. In actual applications, you need to pay attention to configuration details, error debugging and performance optimization.

What happens if session_start() is called multiple times? What happens if session_start() is called multiple times? Apr 25, 2025 am 12:06 AM

Multiple calls to session_start() will result in warning messages and possible data overwrites. 1) PHP will issue a warning, prompting that the session has been started. 2) It may cause unexpected overwriting of session data. 3) Use session_status() to check the session status to avoid repeated calls.

NGINX and Apache: Understanding the Key Differences NGINX and Apache: Understanding the Key Differences Apr 26, 2025 am 12:01 AM

NGINX and Apache each have their own advantages and disadvantages, and the choice should be based on specific needs. 1.NGINX is suitable for high concurrency scenarios because of its asynchronous non-blocking architecture. 2. Apache is suitable for low-concurrency scenarios that require complex configurations, because of its modular design.

Composer: Aiding PHP Development Through AI Composer: Aiding PHP Development Through AI Apr 29, 2025 am 12:27 AM

AI can help optimize the use of Composer. Specific methods include: 1. Dependency management optimization: AI analyzes dependencies, recommends the best version combination, and reduces conflicts. 2. Automated code generation: AI generates composer.json files that conform to best practices. 3. Improve code quality: AI detects potential problems, provides optimization suggestions, and improves code quality. These methods are implemented through machine learning and natural language processing technologies to help developers improve efficiency and code quality.

What is the significance of the session_start() function? What is the significance of the session_start() function? May 03, 2025 am 12:18 AM

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.

Beyond the Hype: Assessing Apache's Current Role Beyond the Hype: Assessing Apache's Current Role Apr 21, 2025 am 12:14 AM

Apache remains important in today's technology ecosystem. 1) In the fields of web services and big data processing, ApacheHTTPServer, Kafka and Hadoop are still the first choice. 2) In the future, we need to pay attention to cloud nativeization, performance optimization and ecosystem simplification to maintain competitiveness.

HTML as a Markup Language: Its Function and Purpose HTML as a Markup Language: Its Function and Purpose Apr 22, 2025 am 12:02 AM

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

See all articles