I’m very new to coding in general, but for a hobby/work challenge I bought the kevin yank book about how to build your own database driven website (excellent for newbs like me) - and I am really enjoying a rekindled love of computers!
I was wondering if there was a way in which i could view others peoples php live on websites, for example index.php? Is there a way to view these on exitign websites?
I think that seeing and hopefully understanding how other put projects together would really help be step forward on this massive learning curve!
No, not possible. PHP is processed server-side and never reaches the user’s browser. It is basically a set of instructions that the server carries out before sending the HTML etc to the browser. It’s kind of like instructions for the king’s meal. The king is just served the meal, not the list of instructions for making the meal.
Addition to ralph:
Not only PHP but any server side scripts are only interpreted/compiled in the server and are sent to the browser normally as HTML. So none of the server side scripts can be viewed from the client’s computer. For more details see http://en.wikipedia.org/wiki/PHP.
Also, look at Google Code Search, constrain it to PHP and you will pull out all kinds of examples.
This is especially useful if you want to know more about a function, and you still cannot grasp what it is for after reading the online manual and the associated user notes.
I suppose you could also search google for .phps files (files which generally show source code, if the server is set up to do so, and the author is of a mind to share the source code).
This was my reply to a similar question in another thread.
I’ll summarise quickly what normally happens.
1) Say you have a plain vanilla html file with some optional javascript and css.
When someone points to that page on your server, the web server sends the html file back to the requestors browser and the browser processes the html, javascript and css and eventually displays your web page’s content in their browser
2) Say you now have some php code as well in the same html file as in 1).
The file should now have a .php extension. This .php extension tells the web server that when someone points their browser to that .php file, the server should first send that php file to the php “engine” on the server. The php engine then reads through that php file line by line and ouputs any html, js,css code unaltered and processes any php code between <?php ?> tags as it comes across them. Any output from the php code is then inserted in place of the php code in the original php file. When the entire .php file has been read and processed by the php engine, the resultant output , which is now just plain html with the original js, css and output from the php code is sent back to the requestors browser and processed by the browser as in 1).