View php pages source code from browser

Asked By 0 points N/A Posted on -
qa-featured

Why am I unable to view a php pages source code from my browser?

SHARE
Best Answer by Sharath Reddy
Answered By 0 points N/A #83226

View php pages source code from browser

qa-featured

Because all the PHP is executed on the server before it is sent to your browser. therefore, all your browser ever receives is the results of the PHP. For this same reason, you cannot go to a .php file on the web, save it, and expect to see how it works. You are only saving the page produced by the PHP, and not the PHP itself.

Here is an example:

 <?php
 Echo "My PHP Page";
 ?> 

We can see that the PHP code is echoing the line My PHP Page, however, it is the server that reads this code and then knows to send My PHP Page to your browser. Since the rest of the code is just instructions for the server, it doesn't send anything else. So a view source or a save will simply be the text My PHP Page.

 

Best Answer
Best Answer
Answered By 590495 points N/A #83227

View php pages source code from browser

qa-featured

 

If you are just an amateur web designer or merely a user who wants to learn the basics of designing a web page, the easiest way is to copy from a very simple website without any great styles applied. The next problem after finding one is how to see or view how the web page is constructed so you can copy and study it. There is no option available in the website and in any other websites that allows a user to view the source code of the page.

But even if it’s not possible from the website, you can still view the page’s source code from within the web browser you are using. You can use your web browser to view how the site’s page is constructed and then copy it in notepad or any text editor and then save it for your own reference. The tool used in viewing the source code of web pages is called View Source or sometimes named as Source. It is usually activated by pressing CTRL + U.

The location of this tool varies depending on the web browser you are using like for example in Opera browser, you can find it in View menu and in Maxthon it is available under Tools menu. Here’s how you can use this tool. First, visit a website then wait for the page to finish loading. Next, from your keyboard press CTRL + U. A new tab will open showing the source code of the page you are visiting. Simply copy all the texts in a text editor and then save it so you can study it later.

Related Questions