Jump to content

php vs. javascript tasks? framework or no?


Recommended Posts

pretty much a newbie with a website and some tutored php code, and mysql connection/table; reading about javascript and php frameworks, the capabilities seem very similar, so wondering:

1) can js do everything php can? interface with mysql?

2) after finishing reading php 6 and mysql (larry ullman), should i learn a couple frameworks (zend/jquery or yui) or just code from scratch?

 

this for website with text responses from forms (want to expand to more variables and use functions which i know nothing about but seem cool, and eventually call database or third party info (google etc.) which would be edited according to form response values):

www.releasecenter.org

 

thanks for advice!!

Link to comment
https://forums.phpfreaks.com/topic/133748-php-vs-javascript-tasks-framework-or-no/
Share on other sites

As far as I know, JS can't connect to MySQL. That's what PHP does. You can request things from MySQL through PHP using AJAX. As for frameworks, I don't use a PHP Framework but I do use a JavaScript framework (jQuery). I only learnt the one JS framework though, thought that it would be enough.

I guess it comes down to personal preference though.

so php for database, and js for calling files and effects? can js insert/get values into/from another file(s) acting like database tables?

 

on my site i've got js for date, capitalize first letter in name field, and third party geolocation. besides what i'm using and effects, what else is js useful for over php? 

 

from what i've read seems that js framework is a good idea and less use php framework. true?

 

thanks!!

so php for database, and js for calling files and effects? can js insert/get values into/from another file(s) acting like database tables?

You can use AJAX to make PHP and JS communicate. Which is where you see forums that tell you if your username is already taken before you submit the form. It simply uses AJAX to send a request to a PHP file that checks the database for the username you entered, then returns a value that you can check with JS and then set an image as either a tick or a cross.

 

on my site i've got js for date, capitalize first letter in name field, and third party geolocation. besides what i'm using and effects, what else is js useful for over php? 

Well, they are hard to compare really. They are made for different things in mind. PHP acts on the server-side, so everything is done before it is displayed to the user. JS, however, is client-side. So JS can be used while the page is loaded. But JS can be disabled by the user, PHP can not.

 

from what i've read seems that js framework is a good idea and less use php framework. true?

I, and probably a lot of people, prefer JS frameworks. I don't use PHP frameworks though, its just a matter of personal preference.

On general remember this:

 

JavaScript executes on client computer. So:

1. User has to download your code => keep your JavaScript files reasonably sized

2. User will see you code => don't put anything security related into JavaScript

3. User can modify your code => validate all data sent from browser using server-side scripts.

 

And last but not least, if you have to do some calculations, better do them in PHP. You'll get results faster (in most cases).

thanks, those comments are helpful. think i'm getting it...javascript can be used as a supplement to enhance php forms and user experience.

 

but how about the main content? in php i've used cases, variables/values and switch statements. can these be done using javascript? or better to keep using php? 

 

 

Eh yeah.... I guess I should revise my earlier statement to go something like:

 

"You should try to avoid using JavaScript to make the output look a certain way, unless your site will definitely have to depend on JS."  Then again, there are very few sites out there that can actually justify not having the site work with JS disabled.

I posted previous message, because I'm developing an intranet application, where all GUI is JS based. But I can afford it. Since its intranet, I say what browser to use and how to configure it. It sure makes thing easier. ;)

Yeah....

 

 

I personally thing it's fine for some sites to depend on JS.

 

For example, I don't know if facebook depends on JS or not (although I know it uses it a ton), but chances are, most people going there will have JS enabled, and if they don't, they will be willing to enable it, so they don't really have to worry about it.

 

Also, if one of the major features of a site is actually it's use of JavaScript, then it's ok too.  (Which is what it sounds like in your case.)

PHP should be used to output data to the client.

 

Javascript can (not should) be used to manipulate the data sent to the client.  The PHP script should never rely on JavaScript to make its output look right.

 

this really puts both in perspective—thanks.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.