php文件怎么打開 如何執(zhí)行php文件
Jun 13, 2016 pm 12:04 PM
什么是php:
PHP,是英文超級(jí)文本預(yù)處理語言Hypertext Preprocessor的縮寫。PHP 是一種 HTML 內(nèi)嵌式的語言,是一種在服務(wù)器端執(zhí)行的嵌入HTML文檔的腳本語言,語言的風(fēng)格有類似于C語言,被廣泛的運(yùn)用。
php就是網(wǎng)絡(luò)上大家常說的后臺(tái),用來處理數(shù)據(jù)庫等,很多網(wǎng)站都是用php寫的,包括www.baidu.com,www.jb51.net等網(wǎng)站,都是使用php語言寫的。我們的文章都是通過php代碼上傳到服務(wù)器數(shù)據(jù)庫中,然后通過php代碼生成靜態(tài)的。
php文件如何打開:
簡(jiǎn)單一句話php跟txt(文本文檔)一樣,記事本就可以打開,但看到的就是代碼,而不是php執(zhí)行后的效果了,例如 我們打開test.php代碼 因?yàn)榫幋a有g(shù)bk或utf8格式的,用記事本打開utf8格式的php文件時(shí),當(dāng)有中文的時(shí)間就是出現(xiàn)亂碼,所以我們建議用dreameweaver或editplus等支持utf8格式文件的軟件打開。(普通用戶選擇editplus打開即可,因?yàn)閑ditplus比較小)
一段php測(cè)試代碼
復(fù)制代碼 代碼如下:
for($i=1;$iecho $i.'
';
}
echo "www.jb51.net";
?>
但是大家目的往往不是想看到這樣的代碼,如果想看到執(zhí)行后的效果,就需要配置php運(yùn)行環(huán)境了。
大家訪問的www.jb51.net都是服務(wù)器端事先配置好的php運(yùn)行環(huán)境,可能是linux也可能是windows,大家在購(gòu)買空間的時(shí)候問下idc商,問他們是否支持php,要不以后購(gòu)買了不支持php的空間,也是無法支持php的。
如果大家是本地測(cè)試php代碼的,大家可以用一些工具例如phpnow等(phpnow安裝使用比較簡(jiǎn)單,安裝以后將php文件復(fù)制到htdocs目錄,在瀏覽器中輸入http://127.0.0.1即可,如果選擇了端口需要加入端口http://127.0.0.1:端口號(hào)),iis也可以,但需要稍專業(yè)的人員來配置。這里我們也為大家提供一下iis php運(yùn)行環(huán)境。前提是您的電腦中有iis,一般默認(rèn)個(gè)人電腦都是沒有安裝的,支持iis的操作系統(tǒng)一般是 winxp,win2003系統(tǒng)。
如果架設(shè)好了php運(yùn)行環(huán)境,在瀏覽器中輸入網(wǎng)址,就可以看到php的運(yùn)行效果(注:大家在瀏覽器中輸入的網(wǎng)址可能不一樣,我們這個(gè)是內(nèi)網(wǎng)ip)
如下圖所示:
很多沒有基礎(chǔ)的朋友,經(jīng)常會(huì)問php文件怎么打開,其實(shí)PHP是一個(gè)網(wǎng)頁腳本,但不同于html xml 標(biāo)簽語言,直接可以通過瀏覽器打開,需要有PHP運(yùn)行環(huán)境才可以訪問和打開文件,如果只是編輯PHP打開文件,只需要用記事本或者通過相關(guān)的編輯器如(DW、EclipsePHP、editplus 等)打開編輯即可。
再來介紹PHP是什么,增加點(diǎn)PHP基礎(chǔ)知識(shí),PHP,是英文超級(jí)文本預(yù)處理語言Hypertext Preprocessor的縮寫。PHP 是一種 HTML 內(nèi)嵌式的語言,是一種在服務(wù)器端執(zhí)行的嵌入HTML文檔的腳本語言,語言的風(fēng)格有類似于C語言,被廣泛的運(yùn)用。PHP的另一個(gè)含義是:菲律賓比索的標(biāo)準(zhǔn)符號(hào)。
我們?cè)趯W(xué)習(xí)網(wǎng)站建設(shè)的時(shí)候,初期接觸較多的肯定是HTML語言,動(dòng)態(tài)語言肯定是ASP。但隨著網(wǎng)絡(luò)的發(fā)展,以及主機(jī)方向的轉(zhuǎn)變,尤其是海外主機(jī)較多的還是LINUX系統(tǒng),WIN系統(tǒng)很少,而且很貴。所以迫使我們也去選擇LINUX主機(jī),使用PHP語言的程序。有些朋友提問,PHP語言的網(wǎng)站怎么打開。這個(gè)問題其實(shí)很簡(jiǎn)單,不管用什么語言網(wǎng)頁,我們都可以用DW或者EDITPLUS或者記事本打開。
但調(diào)試PHP程序不同于ASP這么簡(jiǎn)單,我們可以直接在PHP空間調(diào)試或者安裝本地環(huán)境,我現(xiàn)在使用的PHPNOW或者WAMPSERVER,都是不錯(cuò)的工具。

Hot AI Tools

Undress AI Tool
Undress images for free

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

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

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

The key to setting up PHP is to clarify the installation method, configure php.ini, connect to the web server and enable necessary extensions. 1. Install PHP: Use apt for Linux, Homebrew for Mac, and XAMPP recommended for Windows; 2. Configure php.ini: Adjust error reports, upload restrictions, etc. and restart the server; 3. Use web server: Apache uses mod_php, Nginx uses PHP-FPM; 4. Install commonly used extensions: such as mysqli, json, mbstring, etc. to support full functions.

The key to writing PHP comments is to clarify the purpose and specifications. Comments should explain "why" rather than "what was done", avoiding redundancy or too simplicity. 1. Use a unified format, such as docblock (/*/) for class and method descriptions to improve readability and tool compatibility; 2. Emphasize the reasons behind the logic, such as why JS jumps need to be output manually; 3. Add an overview description before complex code, describe the process in steps, and help understand the overall idea; 4. Use TODO and FIXME rationally to mark to-do items and problems to facilitate subsequent tracking and collaboration. Good annotations can reduce communication costs and improve code maintenance efficiency.

Comments cannot be careless because they want to explain the reasons for the existence of the code rather than the functions, such as compatibility with old interfaces or third-party restrictions, otherwise people who read the code can only rely on guessing. The areas that must be commented include complex conditional judgments, special error handling logic, and temporary bypass restrictions. A more practical way to write comments is to select single-line comments or block comments based on the scene. Use document block comments to explain parameters and return values at the beginning of functions, classes, and files, and keep comments updated. For complex logic, you can add a line to the previous one to summarize the overall intention. At the same time, do not use comments to seal code, but use version control tools.

The key to writing good comments is to explain "why" rather than just "what was done" to improve the readability of the code. 1. Comments should explain logical reasons, such as considerations behind value selection or processing; 2. Use paragraph annotations for complex logic to summarize the overall idea of functions or algorithms; 3. Regularly maintain comments to ensure consistency with the code, avoid misleading, and delete outdated content if necessary; 4. Synchronously check comments when reviewing the code, and record public logic through documents to reduce the burden of code comments.

TolearnPHPeffectively,startbysettingupalocalserverenvironmentusingtoolslikeXAMPPandacodeeditorlikeVSCode.1)InstallXAMPPforApache,MySQL,andPHP.2)Useacodeeditorforsyntaxsupport.3)TestyoursetupwithasimplePHPfile.Next,learnPHPbasicsincludingvariables,ech

PHPblockcommentsareusefulforwritingmulti-lineexplanations,temporarilydisablingcode,andgeneratingdocumentation.Theyshouldnotbenestedorleftunclosed.BlockcommentshelpindocumentingfunctionswithPHPDoc,whichtoolslikePhpStormuseforauto-completionanderrorche

ToinstallPHPquickly,useXAMPPonWindowsorHomebrewonmacOS.1.OnWindows,downloadandinstallXAMPP,selectcomponents,startApache,andplacefilesinhtdocs.2.Alternatively,manuallyinstallPHPfromphp.netandsetupaserverlikeApache.3.OnmacOS,installHomebrew,thenrun'bre

The key to writing PHP comments is clear, useful and concise. 1. Comments should explain the intention behind the code rather than just describing the code itself, such as explaining the logical purpose of complex conditional judgments; 2. Add comments to key scenarios such as magic values, old code compatibility, API interfaces, etc. to improve readability; 3. Avoid duplicate code content, keep it concise and specific, and use standard formats such as PHPDoc; 4. Comments should be updated synchronously with the code to ensure accuracy. Good comments should be thought from the perspective of others, reduce the cost of understanding, and become a code understanding navigation device.
