Hey, I was just interested in know if there are a lot of jobs that PHP and JavaScript both can cover? I am learning JavaScript and know very little PHP but they seem to do the same job in some cases and I just wondered if there is a lot of these similarities.
There are a very few things that both languages can do, but generally you can't even compare them as they're two different things. Javascript runs on the client's browser and can't do anything beyond that. PHP runs on the server and can handle anything that JavaScript can't. (Databases, user authentication, etc...)
Also, using Javascript makes you dependant on the user's settings, because you are able to disable Javascript in your browser. Execution of PHP code only depends on your web server. A user is not allowed to change that Furthermore, with Javascript, the actual code is delivered to the user, so he can see how you program. He could also easily steal it. PHP code runs on the server, so what the user sees is not the PHP code, only the generated HTML site (or whatever you like to generate with PHP )
there is no any similarities.. because date function returns the date of local computer where php date function returns the date of web server.. javascript is a client side scripting where php is server side scripting...
The programming structure is the same. if (string == 1) { document.write('sting is equal to 1'); } else { document.write('sting does equal to 1'); } if ($string == 1) { print('string is equal to 1'); } else { print('string does not equal to 1'); } Code (markup):