Click to See Complete Forum and Search --> : PHP Overview
benjamin
03-26-2004, 05:29 AM
I am thinking about learning PHP but am not exactly sure what it really is. What are its uses? Is it easy to learn? Is it a server side language and does it have to use external files?
I have a good understaning of JavaScript, would this make it easier to learn?
It would be appreciated if somebody could answer these simple questions and / or supply me a link to a website with the answers. Thankyou.
Yes, PHP is a server-side language. It's uses would be similar to that of any other server-side languages, such as Perl or ASP. Form handling, guestbooks, blogs, counters, etc.
Depending on how you define "easy", yes, I'd say that PHP is fairly easy to learn, especially if you are fairly knowledgeable about JavaScript (or almost any other programming language, for that matter). If you are familiar with programming in general, learning PHP is more just learning the functions and syntax than anything.
To learn more about PHP, check out http://www.php.net/.
scottO
03-26-2004, 01:57 PM
Originally posted by benjamin
I am thinking about learning PHP but am not exactly sure what it really is. What are its uses? Is it easy to learn? Is it a server side language and does it have to use external files?
What exactly do you mean by "external files?" You can include PHP directly into the page like so:
<?php
# code here
?>
Originally posted by benjamin
I have a good understaning of JavaScript, would this make it easier to learn?
I too have a good understanding of Javascript. I'm learning PHP right now, and, so far, it's fairly easy, although I haven't started using MySQL yet.
Most of the operators, loops, the basics, are pretty much the same. There's no "for (x in array1)," but there's something similar.
One of the main things I've noticed is: If you want to change a string, you don't do "mystring.toUpperCase()" you would do "strtouc($mystring)"
PHP seems less object-oriented.
Originally posted by scottO
PHP seems less object-oriented.
Actually it has the ability to create classes and object-oriented functions as well--they are just used less commonly. It depends how you program, really. I think both JavaScript and PHP are very similar, but the manual says that PHP is created from C, Perl and Java (not JavaScript). JavaScript is probably created from Java. So PHP has quite a mix.
[J]ona
While PHP does have the ability to create classes and objects, it is not truly object oriented, nor is it meant to be. There is, however, supposed to be much better support for objects in PHP 5...
In php you will find a lot of functions which you want to have in javascript...
fredmv
03-26-2004, 02:37 PM
Originally posted by olaf
In php you will find a lot of functions which you want to have in javascript... Maybe some of the string manipulation and other such functions, but functions for querying databases and sending mail should and always will remain within server-side languages because that is what they were created for. Client-side languages were not meant for these kind of tasks hence why they do not include such functionality. Much like PHP cannot dynamically update elements of the page (via DOM functionality) or other similar things — it's just not what it was intended for.
Yes, you are right there are good and bad points. But the foreach and elseif function is really usefull...
fredmv
03-26-2004, 03:00 PM
Originally posted by olaf
But the foreach and elseif function is really usefull... The foreach statement, if I'm not mistaken, is implemented in JavaScript as for/in. As for elseif, it isn't a function but rather a statement, and is in JavaScript but as else if (i.e., two words).
else if works in PHP as either one or two words. I personally perfer two. ;)
jabez
03-26-2004, 04:37 PM
Hi Ben.
I found O'reillys book 'PHP Pocket Reference' very handy.
It gives a brief and concise overview of the core language features of PHP.
More details should be at www.oreilly.com
Jabez
Originally posted by pyro
else if works in PHP as either one or two words. I personally perfer two. ;)
OK i wil give ot a try, next time
Originally posted by fredmv
The foreach statement, if I'm not mistaken, is implemented in JavaScript as for/in. As for elseif, it isn't a function but rather a statement, and is in JavaScript but as else if (i.e., two words).
The for/in: Never saw it before do you have a short example for this:
foreach($ob as $key=>$val) {
do something...
}
scottO
03-27-2004, 12:40 AM
Originally posted by olaf
The for/in: Never saw it before do you have a short example for this:
foreach($ob as $key=>$val) {
do something...
}
for(key in ob) {
var val=ob[key];
// do something
}
I think that's it.