 |
|
|
|
12-20-2005, 11:57 PM
|
PHP vs Javascript
|
Posts: 21
|
Hello everyone,
I am currently an advanced PHP coder, but like all coders, I still have much to learn. One of my friends is a JavaScript coder, and we are always arguing (friendly of course), about which is better: PHP or JS.
I know a lot of ways PHP is better than JS, but JS has its advantages too. So I was just hoping that you guys could give me reasons why PHP is better than JS. Then later I'll have a list of reasons that I can tease him with. :P Feel free to go into detail.
Thanks,
DJ -- someotherguy
Last edited by someotherguy582; 12-21-2005 at 08:34 AM..
|
|
|
|
12-21-2005, 04:19 AM
|
|
Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
|
<whisper> This isn't coding forums.com </whisper>
Chalk and cheese
PHP = Server Side vs Javascript = Client Side
Both operate in different mediums on opposite sides of the HTTP fence
__________________
Chris. ->> Please login or register to view this content. Registration is FREE <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
|
|
|
|
12-21-2005, 06:19 AM
|
|
Posts: 251
Location: Belgium, Antwerp, Zoersel
|
Like chrishirst says, you can't really compare them. Normally, you use them both. Javascript for the nice dynamic client side stuff (like hiding a part of the page) and PHP to generate the page. And then there's ajax, which makes both work really great together.
|
|
|
|
12-21-2005, 06:49 AM
|
|
Posts: 880
Location: Leeds UK
|
AJAX is cool, been getting into it for a month or so now and i must say it puts client/ server scripting into perspective.
If you have not given it a go then I suggest trying it out, Its got serious potential.
Ibbo
|
|
|
|
12-23-2005, 04:34 AM
|
|
Posts: 82
|
Ooh, here's an easy one...
All browsers support the output of PHP code, but it's so common these days that, due to security concerns, loads of people will be declining to allow JS to function in their browsers unless on a fully trusted site.
PHP or JS? Each has it's uses, but try to opt for PHP to avoid the temptation of using JS for unecessary client-side trickery!
Do you not think that PHP is actually the easier option also?? Heh heh, just a thought!
Enjoy 
|
|
|
|
12-23-2005, 06:37 AM
|
|
Posts: 880
Location: Leeds UK
|
As for coding of each.
I beleive once you know one language you can get by in them all (save lilsp).
But JS can be disabled and if it is not disabled you can be alowing your every key press overy mouse click to be recorded.
Scared YET?
Ajax or more to the point the use of the XMLHttpRequest() method and its subsequent took kit can do this with a breeze and all without even you been aware of it or without having to submit your browser to get the info across.
Of course it can be used for more practical purposes (Google Map) or even knocking up chat systems for your site (which are quite easy to do).
The pro's outweigh the cons with JS.
Just dont go to malicious websites or your aking for trouble.
Ibbo
|
|
|
|
12-24-2005, 05:42 PM
|
|
Posts: 4
Location: Here.
|
mmm... i thought and this is what i know
PHP have mail function
js, dont have it.
with php you can have the remote and local time
with js you can have user time...
with php you can have remote and host address
with js ... i dont know !!
with php the source is not lookable in the source code
with js the source can be see in the source code of the page.
That's all, may be i am wrong, but i dont know...

|
|
|
|
12-26-2005, 06:40 PM
|
|
Posts: 171
|
I really don't like javascript. I try to use as little as i can of it. But sometimes javascript is very useful.
|
|
|
|
12-30-2005, 09:14 PM
|
|
Posts: 535
|
there is no real debate, its php
__________________
I have the heart of a child, I keep it in a jar on my desk.
|
|
|
|
06-05-2007, 07:18 PM
|
Re: PHP vs Javascript
|
Posts: 21
|
Actually you can make it were you cannot read the JavaScript coding or you can just try to hide it in a .js file (not really good hiding place though)
|
|
|
|
06-06-2007, 02:11 PM
|
Re: PHP vs Javascript
|
Posts: 25
Name: Jason R
|
First, I consider myself a PHP coder first, and a javascript coder a distant second (not counting the other languages I use)..
In order to survive in todays web world you are going to HAVE to know javascript. You don't NEED to know php, but you better know a PHP alternative (PERL, RUBY, ETC).
-Jason
__________________
Please login or register to view this content. Registration is FREE - 15,000+ new domaina names a day starting at $5.
Please login or register to view this content. Registration is FREE - Personal Site/Script Portfolio
|
|
|
|
06-06-2007, 06:39 PM
|
Re: PHP vs Javascript
|
Posts: 6,521
Name: Dan
Location: Swindon
|
I completely agree with wht most people have said ts obvious PHP as a HUGE amont of more potrntial.
I dont think there is really anything javascript can do which php cant (yes somethings might be longer/harder to do it php)
Javascript seems to be a bit of aout dated fad. (im talking about the people which ha loads of unneccisary stuff)
i find sites which use it too much plain annouying!
PHP anyday.
And the litlle bits about Javascript which i did like it seems IE7 dont accept!
ad yet IE6 does :|
i have rambeled enough.
Cya Guys.
Dam
__________________
Discounted Web Hosting With XDnet! >> Get 25% of hosting~ Promo: Webmaster-talk <<
|
|
|
|
06-06-2007, 10:43 PM
|
Re: PHP vs Javascript
|
Posts: 31
|
Neither are better just diefferent purposes. PHP is serverside and JS is browser scripting
|
|
|
|
06-06-2007, 10:47 PM
|
Re: PHP vs Javascript
|
Posts: 486
Name: Matt
|
How can these even be compared.
PHP is better because -
- It is server side in other words if it works on your server it will work for everyone unlike JavaScript where you have to fix it for every browser. JavaScript can be turned off. So for things like JS login forms they can simply get past it. I've done it before.
- There's WAY more functions. We're not talking hundreds. Maybe thousands. I don't know since I don't know every PHP function (who does? Probably no one) but either way PHP can do so much more thinking than JS. Although just to give JS some credit it can do some things PHP can't. But they aren't necessary things.
- No one can see your source code with PHP and therefore no one can steal your scripts EASILY!
- PHP is configurable. You can tell PHP what functions you don't want to be used and what you do want to be used so it is in turn more secure.
Overall though you can't compare the two. It's like comparing which is more powerful. A computer or a human. Computers can remember things for a long time and do long calculations but humans can think for themselves. So even though they both sort of are in the same area they are two entirely different things. How does this apply with PHP/JS?
PHP can dynamically chose what to put on a page and do many background functions such as random numbers, etc. Put all these together you have a powerful application. It is the power behind web applications.
JS can't really THINK or PROCESS for itself (mainly just decide things) but it can do cool things with content that has already been decided on. For instance it could make something pop up.
So they don't do the same things. You can use them together. You know, let's be friends PHP, not enemies. For example you could have PHP generate links on a menu via a database and then have JavaScript make that menu drag and drop-able, expandable, etc. It makes things flashy, surprising, and cool to the user.
One last example. Think of PHP as a cars motor, wheels, etc. All the things that make the car move. Now think of JS as the cool red paint, hub caps (I know hub caps are real ghetto but stick with me), and convertible top. It's what makes the car look cool but has nothing to do with making it run well.
Man I should write a programming book :s. Hope this helps. I can expand further if you need but you're probably sick of hearing the same thing over again XD.
__________________
PHP Code:
$talkupation++;
Please login or register to view this content. Registration is FREE - Free IPB forum hosting (releasing today!!!), no ads, free modifications
|
|
|
|
06-07-2007, 01:49 AM
|
Re: PHP vs Javascript
|
Posts: 565
Name: surajit ray
Location: inside the heart of my friends
|
i agrre with Mattmaul1992, there is no way we can compare these two. Both have their own advantages and downside as a progamming language.
__________________
I am not smart, that's why i don't act smart
Please login or register to view this content. Registration is FREE
|
|
|
|
06-07-2007, 05:35 PM
|
Re: PHP vs Javascript
|
Posts: 21
|
Sure you can compare the 2. JavaScript is better. I will tell you why:
1st JavaScript is Extremely flexible in what it can and can't do. Actually if you really wanted to (not recommended) you could run JavaScript as the server-side and client-side program on the same site.
2nd- Yes you can by pass a password by turning JavaScript off but, you could add an HTML form or some sort.
3rd PHP is way tooo slow of a program to type out, you could use the Microsoft server-side language instead of PHP and get the Job done alot faster with their tool managers (PHP is very restrictive in that area).
4th Also if anyone didn't here me in my last post you can encrypt your JavaScript files so no one can steal them easily (You need a back up file to see what you wrote though).
5th Also with JavaScript in its AJAX form makes your website run very smooth like a desktop application. Something that PHP could not do very easily if not at all.
There are so much more things that JavaScript can do than it can't. In other words the Pros way out weight the Cons.
PHP is a great language but, there are alternative languages that you can use to do the same thing as PHP could but, you can get the job done much faster.
Shadow9997
|
|
|
|
06-07-2007, 09:20 PM
|
Re: PHP vs Javascript
|
Posts: 4
|
Well I say PHP, and instead of going over the same points here I will say PHP is better because more people are hiring PHP coders. There was a post on dzone that shows interest per language http://feeds.dzone.com/~r/dzone/fron...ava_dying.html
no not scientific but interesting
__________________
Earn more per Please login or register to view this content. Registration is FREE 24/7.
|
|
|
|
06-07-2007, 09:49 PM
|
Re: PHP vs Javascript
|
Posts: 486
Name: Matt
|
Quote:
Originally Posted by Shadow9997
Sure you can compare the 2. JavaScript is better. I will tell you why:
1st JavaScript is Extremely flexible in what it can and can't do. Actually if you really wanted to (not recommended) you could run JavaScript as the server-side and client-side program on the same site.
2nd- Yes you can by pass a password by turning JavaScript off but, you could add an HTML form or some sort.
3rd PHP is way tooo slow of a program to type out, you could use the Microsoft server-side language instead of PHP and get the Job done alot faster with their tool managers (PHP is very restrictive in that area).
4th Also if anyone didn't here me in my last post you can encrypt your JavaScript files so no one can steal them easily (You need a back up file to see what you wrote though).
5th Also with JavaScript in its AJAX form makes your website run very smooth like a desktop application. Something that PHP could not do very easily if not at all.
There are so much more things that JavaScript can do than it can't. In other words the Pros way out weight the Cons.
PHP is a great language but, there are alternative languages that you can use to do the same thing as PHP could but, you can get the job done much faster.
Shadow9997
|
Here's my thoughts on that -
1. Flexible?
2. Add an HTML form of some sort? JavaScript would be looking at a form fields value. How is another form going to help anything?
3. Have you every made a real PHP program? To print something to the screen in JS you have to do "document.write.ln (\"Some value\");" in PHP it's just "print 'hello';". PHP programs are usually longer in length because they do more. And "Microsoft Server-Side Language" is called ASP (Active Server Pages). It is just as long and harder.
4. It's not really encryption. It's just messing it up to be real hard to read. It's as simple to 'unencrypt' it as it was to 'encrypt' it. In fact most JS encrypters have a decrypter right below the encrypter.
5. You obviously don't fully understand what AJAX is. AJAX is mixing PHP with JavaScript so right there you're just supporting PHP and not even knowing it.
__________________
PHP Code:
$talkupation++;
Please login or register to view this content. Registration is FREE - Free IPB forum hosting (releasing today!!!), no ads, free modifications
|
|
|
|
06-08-2007, 04:14 PM
|
Re: PHP vs Javascript
|
Posts: 21
|
Quote:
Originally Posted by Mattmaul1992
Here's my thoughts on that -
1. Flexible?
2. Add an HTML form of some sort? JavaScript would be looking at a form fields value. How is another form going to help anything?
3. Have you every made a real PHP program? To print something to the screen in JS you have to do "document.write.ln (\"Some value\");" in PHP it's just "print 'hello';". PHP programs are usually longer in length because they do more. And "Microsoft Server-Side Language" is called ASP (Active Server Pages). It is just as long and harder.
4. It's not really encryption. It's just messing it up to be real hard to read. It's as simple to 'unencrypt' it as it was to 'encrypt' it. In fact most JS encrypters have a decrypter right below the encrypter.
5. You obviously don't fully understand what AJAX is. AJAX is mixing PHP with JavaScript so right there you're just supporting PHP and not even knowing it.
|
Here is what I think about what you just said:
1. Flexible...JavaScript? If you are asking yourself this question you more than likely don't know much about it. You probably know only Client-side JavaScript. What I mean is that there are 2 different JavaScripts, there are Core-JavaScript and Client-Side. Client Side is the easiest and the most used side of the language. Then there is Core-JavaScript which can do just about everything else.
2. When I said add a HTML form or sort I am saying is that Client-Side JavaScript is a script base language which use the <script> tags. Well they do end and when they do you could add a different language there for the form.
3. Also really you say PHP is easier than JavaScript but, you seem you don't know enough about JavaScript to understand it. Yes, you do have all of the document.write() tags but, its client-side (specialty). What does PHP look in client-side? The same maybe if not more code, or you couldn't do it at all.
-ASP, you say it is harder and longer. Have you every written in ASP? I know a guy that I talk to about every day that has been witting ASP for about 10 years. You can get tools from Microsoft that makes witting ASP a piece of cake. You could get the same exact page in ASP in about half the time you could in PHP and it does virtually the same thing. (He's written sites for a lot of companies including, Sony)
4. When I said encryption I was using it as an option not a solution. Now if you get a good encrypter your language will look like machine language (ie. a bunch of 0's and 1's), plus who is going to take the time to 1st find your site, find a un-encrypter, and try to un-encrypt it. For just a couple of lines of code which, you could have probably wrote in the time it took you to find it out. Plus if it was something important you would write it in ASP.
5. I Actually you might not understand AJAX as much as you think you know. You can write it with JavaScript or any other client-side scripting language. AJAX makes JavaScript run like a Desktop application (a must for all good websites). Plus a well written AJAX program will be able to take all of the users information, key strokes, everything that the mouse passes over, ect. And that is very impressive with a so called, "Client-Side" only website Language that is design just to spice up your site.
If you write AJAX (with JavaScript) here are the JavaScript language "styles" and technologies that it includes:
-XHTML ( Extensible HyperText Markup Language)
-CSS (Cascading Style Sheets)
-The DOM (Document Object Model) accessed through JavaScript
-XML (Extensible Markup Language)
-XMLHttpRequest (XHR) or (Extensible Markup Language Hypertext Transfer Protocol Request) Whew that was long .
So AJAX through JavaScript uses all of those Technologies (listed above) and yet you still suggest that PHP is more "Flexible", "easier", and can do more? Also on the server-side ASP is just GREAT with all of its tools. And as you see above there is no PHP in the list because you can use any server-side language of your choice. ASP being the preferred.
The only reason ASP isn't on the list of great languages to learn is because it was developed by Microsoft and there are a lot of Microsoft haters our there.
-Shadow9997
|
|
|
|
06-08-2007, 08:47 PM
|
Re: PHP vs Javascript
|
Posts: 253
Location: Constanta,Romania
|
You can't compare these to coding languages. Like most of the people said php is server side and JS is client side. These two cannot be compared.
However: can live w/o php? Of course, there are a lot alternatives.
Want a nice site? Can't live w/o JS.
|
|
|
|
|
« Reply to PHP vs Javascript
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|