说一个很多菜鸟(例如小弟我)都遇到的有关问题的解决办法,当然这个解决办法却引出另一个有关问题,求解!
说一个很多初学者(例如我)都遇到的问题的解决方法,当然这个解决方法却引出另一个问题,求解!!
大家(超级初学者们),是不是都试过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

AI Hentai Generator
Generate AI Hentai for free.

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

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Validator can be created by adding the following two lines in the controller.
