说一个很多菜鸟(例如小弟我)都遇到的有关问题的解决办法,当然这个解决办法却引出另一个有关问题,求解!
说一个很多初学者(例如我)都遇到的问题的解决方法,当然这个解决方法却引出另一个问题,求解!!
大家(超级初学者们),是不是都试过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.
------解决方案--------------------
必须要以“主机名”来访问才能被apache解析。localhost 就代表本机。
------解决方案--------------------
我前几天也遇到同样的情况,lz说的是一种,但是要是单单浏览页面的话,也可以把.php文件改成.html的,可以放到电脑的其它位置正常浏览,不会只显示源代码
------解决方案--------------------
你重心放错地方了,你的重心应该是如何运用PHP,而不是配置PHP环境,就像你用电脑,但不一定需要知道电脑的运行机制的。配置运行环境你只需要大概了解就行,不需要太深入。以后弄PHP,直接用集成安装包弄就行了。
------解决方案--------------------
这应该是个常识吧,不放在解析目录里,当然不会被解析,当然,这个目录不一定是固定的,也可以设置的
------解决方案--------------------

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.
