question about PHP

@migenKC (792)
Philippines
May 7, 2008 11:22pm CST
i was on my JavaScript class when my teacher asked everybody what is the difference of PHP and JS as scipts.. one of my classmates answered it with confidence and said "PHP is server based script while JavaScript is a client based" my teacher explained it further but i still did not understand the point. could someone from explain me the exact difference between the two of them and which do you think is better to use.. my teacher was favorable to JS. (maybe that is why it is the subject he teaches..duh!!) tnks guys..hopefully someone can explain to me..
1 person likes this
4 responses
@cnetboss (2473)
• Philippines
22 May 08
PHP Programming - PHP Programming logo
Ok in laymans explaination. Client-side programming like Javascript are web application codes which can function independently, meaning all web applications/codes can be work without the use of a web server. On the otherhand. PHP is server-side programming language much like ASP and ASP.Net which needs a web server or a localhost server to be able to for functions to work. Hope I explained your question:D
@killer_r (42)
• Indonesia
19 May 08
I think the others have mentioned the definition. The point is that: Server-side script will be run on the server, the code will be in the server only, and we can only get the result. Client-side script will be run on the client, the code will be downloaded and then run in our web browser. Example: You want to create a login page. If using PHP (Server-side), the process will be done in the server (web server, the hosting provider) so the user can not view the login process. While JS download the script, and thus make the script available to see or even edit. Which one is better to use, I can't say because they are in two different world. PHP is usually used in more secured situation, while JS in less secured. And JS is usually used to enhanced the interface. Hope this help :)
@Araiya (61)
• United States
8 May 08
The simplest way I can explain it is this: php requires a web server (Examples: Apache, nginx, Lighttpd, roxen, Microsoft Internet Information Server (IIS)) capable of parsing (sort of like 'speaking') php. This can be added to most web servers by the server's administrator / owner. If your host does not offer php, you're stuck in the water with any php script. You'd either have to get the host to install php, switch to a host that already has php installed and available. JavaScript, on the other hand, only requires a web browser (Examples: Epiphany, Galeon, Firefox, Seamonkey, K-Meleon, Opera, Safari... oh, and that big blue e) that is relatively recent enough to have JavaScript support built in. Most browsers developed in the last eight years or so generally can support JavaScript, as long as it has not been disabled by the (l)user. Nothing special needs to be on the web server. No special abilities need to be on a character sheet. No sacrifices need to be made to the elder gods. Just put your JS to use in an HTML document, and let it rip. Honestly, I'd put some php and JS together, since each has its place. php can generally interact more with things on the server, making it suitable for the moderate work like managing an image gallery, editing images, interacting with databases, etc. JavaScript is good for the light work, and is one of the things that makes up Asynchronous Javascript And XML. :)
• Indonesia
9 May 08
Server Side Scripting: - Placed on the server only(client can not download this script) - The script will be running on the server - The client/user won't be able to see the script Example:You have a web using PHP script that get user name and password from the user who wants to log in to your website.(You can imagine it similar to the login page of mylot.com or yahoo or whatever....) What happened on the user/client pc is: send user name and password to the server, then receive the result(whether the username and password they entered is correct so they logged in or the username and password they entered is wrong so they can't logged in). What happened on the server: receive user name and password, check if the user name and password is valid or not and send the result to the user pc. You know that in programming there is always input, process, output. You can see that on server based scripting generally the the input is sent form the client to the server, the server process it then the the server send the output to the client. Client Side Scripting: - The client will download the client side script(for example java script) to their computer - The script will be running on the client pc - The client can see the script Example: You have a simple game maybe like a quiz game developed using javascript(client side script) in your web page. When user browse your web page, they will download the whole quizz game script to their pc. After that, the input(your answer), process(check whether the answer is right or wrong) and output(display the result) is done on the client pc. They can play the game again without having to connect to to the server again once the script is on their pc. A quizz game can also be developed using server side scripting like php. In this case the client get the question, send the answer to the server then the server check the answer and send the result to the client pc. So if you play the quizz again, you connect to the server again because the process of checking the answer is done by the server. Each Scripting has advantages and disadvantages. For example if you need security, client based scripting is not a good choice because the client can see your script. There is still much more about it.... But I'm too tired to type.... haha Hope it gives a clearer understanding about the difference...