Page 1 of 2

Vote for the next article - PHP or Javascript

Posted: Wed 15 Jun 2011 10:57 am
by daj
Folks,

Following on from my articles introducing Stylesheets and Web page layout.....

http://wiki.sandaysoft.com/a/Stylesheets
http://wiki.sandaysoft.com/a/Webpage_layout

I'm trying to decide on my next topic -- Javascript or PHP. Both are equally useful to the modern website developer!

Please take a moment to vote -- I will let it run for a week or so and then do which ever one is most popular.

Re: Vote for the next article - PHP or Javascript

Posted: Wed 15 Jun 2011 11:04 am
by mcrossley
David, how about adding JQuery and JSON to your ToDo list?

Re: Vote for the next article - PHP or Javascript

Posted: Wed 15 Jun 2011 11:08 am
by daj
TBH, the Javascript would include jQuery as it makes things much simpler than 'raw' Javascript. I could certainly write something on JSON too but not in an intro article, but maybe on its own.

I think each of these two topics (PHP and JS) spawn a few sub-topics like MySQL, JSON, AJAX techniques. I could be busy :lol:

Re: Vote for the next article - PHP or Javascript

Posted: Wed 15 Jun 2011 11:17 am
by mcrossley
Its funny but the other day I wondered how JQuery performed against raw JavaScript, after Googling for a while it seems it is about 500-600 times slower processing 'large' pages. So the convenience comes at a cost - as ever. Now I really must learn JQuery... :lol:

Re: Vote for the next article - PHP or Javascript

Posted: Wed 15 Jun 2011 10:17 pm
by Graham64
David
I, for one, would find it very helpful if you could add to the excellent articles that you have already written for the Wiki. I have voted for PHP, however what about a brief general article on the what/why/whens of PHP and Javascript?

From reading many of the messages on the forum I can just about understand the programs listed and it seems as though they both can do similar things but I can't find out which is best to use for which purpose.

For example:
  • PHP has the advantage that it is all on the server side - so what?
    Javascript has the ability to do timings, does PHP?
Sorry if these are all very basic questions but I would like to know when to use PHP, when to use Javascript and what are the advantages/disadvantages of both.

These questions could also be applied, it seems, to other choices, for example the different graphing methods that have been quoted on the message board.

Thanks for all your work on the Wiki - very useful.

Graham

Re: Vote for the next article - PHP or Javascript

Posted: Wed 15 Jun 2011 11:12 pm
by bnwrx
Graham64 wrote:David
I, for one, would find it very helpful if you could add to the excellent articles that you have already written for the Wiki. I have voted for PHP, however what about a brief general article on the what/why/whens of PHP and Javascript?

From reading many of the messages on the forum I can just about understand the programs listed and it seems as though they both can do similar things but I can't find out which is best to use for which purpose.

For example:
  • PHP has the advantage that it is all on the server side - so what?
    Javascript has the ability to do timings, does PHP?
Sorry if these are all very basic questions but I would like to know when to use PHP, when to use Javascript and what are the advantages/disadvantages of both.

These questions could also be applied, it seems, to other choices, for example the different graphing methods that have been quoted on the message board.

Thanks for all your work on the Wiki - very useful.

Graham
I second Graham64 ideas. David is so knowledgable on these subjects. I am still trying to understand so much :o
I now have a paid webhost that offers MySql data bases, but I have no idea how to send data to them.... :oops: !!

Re: Vote for the next article - PHP or Javascript

Posted: Thu 16 Jun 2011 9:18 am
by daj
Ok, here are some basics on the different technologies. Broadly speaking (before anyone starts chipping in with the , "Ah, but..." comments) !!


HTML
All web pages are written using the HTML language -- this describes the content of the page and how a page is laid out. HTML is sent from a web server and the browser then displays it.

CSS (Stylesheet)
This is used in conjunction with HTML to style your page (colour, position, etc). Again this is sent from the webserver and the browser uses it to display the page

Javascript
This is a language used by your browser to manipulate the page being displayed on screen. It is always executed on the browser (so all the work is done on the users machine -- pc/mac/phone, etc). JavaScript is supported by all modern browsers, incudling some mobile phones (iPhone, Andriod, etc). The user does have the option to turn off Javascript (some consider it a security risk) however by default it is turned on and most modern sites rely heavily on Javascript. IE has one of the worst iplementations of Javascript (mostly for speed) but is much better in IE8/9

PHP
This is loosely based on the Javascript language (for syntax). It's major difference is that it is run on the webserver BEFORE the HTML page is sent to the users browser. It never runs on the browser. PHP is typically used to add logic/intelligent to a web page. (example,you have data from a Cumulus webtag to say it is raining, so show a picture of a cloud) Whatever output PHP produces must be in HTML. So, when you request a web page from the server containing PHP the web server will execute this, build the resultant page (in HTML), and send the result to the browser. PHP must be enabled on the webserver. Most good hosting firms enable it by default. Most free hosts do not.

When to use JS (Javascript) or PHP ?

Using PHP is much faster (usually) as all the work is done on the webserver (which is fast) and the result is sent to you
Javascript is slower as all the JS code is sent to the browser, then executed on the PC, and the page updated
A user may have JS disabled, so you might need to consider that your page will not work
If you do not have PHP on your webserver you need to use JS!

To be honest, you will probably use both.

If you look at this page...http://www.grantownweather.co.uk/realtime it starts off as PHP so that I can use logic on the web server to build the page and send the results. I then use Javascript to update the page every 30 seconds and highlight changes in yellow.

What about Ajax?
Ajax is, in essence, a concept not a new language. It's basically JavaScript and it works in the background while you are viewing a page on the browser. In the above example, I am actually using Ajax methods to go back to the webserver and get data every 30 seconds; I then use Javascript to update the page layout/content

and jQuery?
This is simply a library of Javascript code (functions). Using jQuery I can use simple commands to do tasks that would take several lines of Javascript. jQuery is Javascript.

any questions? LOL Hope that helped ;)

Re: Vote for the next article - PHP or Javascript

Posted: Thu 16 Jun 2011 10:36 am
by nking
Thanks David - CRYSTAL! :)

Re: Vote for the next article - PHP or Javascript

Posted: Thu 16 Jun 2011 12:22 pm
by Graham64
David
Thanks very much, that is just what I wanted - a concise summary in one place. I, for one, will find it very useful.

What about putting it on the Wiki as a good starting point that can easily be found for those of us new to a lot of the languages etc?

Graham

Re: Vote for the next article - PHP or Javascript

Posted: Thu 14 Jul 2011 10:38 pm
by JennyLeez
Thanks for the summary David.

I see php won the poll so now I wait for my php lessons :)

Re: Vote for the next article - PHP or Javascript

Posted: Sat 17 Dec 2011 11:02 am
by duke
Does the PHP article exist yet? I need to start somewhere :D

Duke

Re: Vote for the next article - PHP or Javascript

Posted: Sat 17 Dec 2011 11:35 am
by steve
David seems to be taking a sabbatical. Hopefully he'll be back before long.

Re: Vote for the next article - PHP or Javascript

Posted: Sun 18 Dec 2011 5:17 pm
by duke
In it's abscence can anyone suggest a good place to start?

Duke

Re: Vote for the next article - PHP or Javascript

Posted: Sun 18 Dec 2011 6:37 pm
by steve
php.net is a good place for information on PHP. There's a getting started tutorial here - http://php.net/manual/en/tutorial.php

Re: Vote for the next article - PHP or Javascript

Posted: Mon 19 Dec 2011 3:25 pm
by gemini06720
Another good Internet location would be W3Schools' PHP Tutorial...