answersLogoWhite

0


Best Answer

They all serve different purposes.

JavaScript is run by the browser (client). Verifying that a form is correctly filled out before submitting is an example of a good use for Java script.

PHP is run by the web server. Verifying that a form was correctly filled out after it has been submitted and then doing something useful with the information in the form is a good use for PHP.

XML is a markup language used to describe (mark up) data.

You can use all three. For example, if I want to make a search box that pops up a list of possible completions for what I'm typing into it, I would use JavaScript to pop up the box. The java script would also load the possible completions from XML, and the XML would be generated by PHP, which would generate the XML based on past searches in a database.

Nobody can decide, which is better java script and XML or php because they all are very useful for web programming. And they all use for different -2 types and purposes.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Which is better JavaScript and XML or PHP?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is XML Parsing?

Extensive MarkUp languageXML parsing is when you convert an XML document into an XML DOM object - which can then be manipulated with a JavaScript.


How can you use a JavaScript variable in the PHP isset function?

You can't actually do that. There is no direct way to make JavaScript code talk to PHP code, as the two languages are interpreted in different locations. The PHP is interpreted by the server, and the JavaScript is interpreted by the client. This means it's easy enough to transfer data from PHP to JavaScript (by generating the JavaScript with the PHP), but not the other way around. If you're simply looking for a way to see if a JavaScript variable is set (from within the JavaScript itself), that can be done with a line like this one: if(myVariable !== undefined){ /* do stuff */} If you actually want to handle it on the PHP side, one way to do so would be to use additional PHP code when that happens. For example: <?php $jsVars = array(); ?> <script type="text/javascript"> var foo = 'bar'; <?php $jsVars['foo'] = 'bar';?> var yub = 'nub'; <?php $jsVars['yub'] = 'nub';?> </script> ... You can then check to see whether a certain variable has been set by seeing if it's in that array: <?php function jsIsset($varname){ global $jsVars; return array_key_exists($varname, $jsVars); } ?> This however, only works when the JavaScript is generated, not when it's interpreted by the client system. For example, imagine you have a variable that is defined by a JavaScript function that is called from an onclick event. By the time that event happens, the page has already been served and the PHP is done executing. If you want the JavaScript to tell the PHP that a variable is defined, you would need to do it through an AJAX request, which I believe is beyond the scope of this question.


How do you use the JavaScript confirm function in PHP?

It has to be done with Javascript. Though you could do something like this:


How do you parse XML using JavaScript?

To manipulate an XML document in javascript, you need an XML parser. Today all browsers come with in-built parsers that can parse the XML document. The parser loads the document into your computer's memory. Once the document is loaded, its data can be manipulated using the DOM(Document Object Model). There is significant differences in implementation of Microsoft Browser based XML parser and the Mozilla browsers based XML parser.


Difference between java script and xml?

It would be harder to describe the similarity between JavaScript and XML. These two languages are for entirely different purposes.

Related questions

How do you connect javascript using php?

Any communication between Javascript code and PHP code needs to be instigated by the Javascript. This is because Javascript is a client side script and PHP is server side. The server can't force data to the browser; it can only reply to requests. The technique of using Javascript on the client side to talk to server side scripts is referred to as AJAX (Asynchronous Javascript And XML). There are several libraries available for simplifying it's usage, and many online tutorials.


Does JavaScript interact with PHP?

Yes, JavaScript and PHP can interact with each other in web development. JavaScript is a client-side scripting language that runs in a user's browser, while PHP is a server-side language that runs on the server. The two languages can communicate with each other through the use of AJAX (Asynchronous JavaScript and XML) requests. JavaScript can make an AJAX request to a PHP script on the server, and the PHP script can process the request and return data back to the JavaScript code. This allows for dynamic, interactive web pages that can update their content without requiring a full page refresh. Overall, JavaScript and PHP are complementary technologies that can work together to create powerful web applications


How do you use XML in PHP?

PHP 5 has a XML parser called SimpleXML that you could use.


What is XML Parsing?

Extensive MarkUp languageXML parsing is when you convert an XML document into an XML DOM object - which can then be manipulated with a JavaScript.


What does Ajax use for the processing that is done on the browser?

Javascript. AJAX stands for Asymmetric Javascript And XML


How do you parse very large XML feeds into MySQL with PHP?

You will use an xml parser like simple xml. If you will focus on timeout/connection time out in curl and script time out in php is set to 0(no limit) it will help.


What are the similarities between PHP and JavaScript?

there are not many similarities, except the if and else statements, loops, etc... but PHP talks to the server, JavaScript can't. That's why both languages have totally different functions. If you only use basic JavaScript, PHP doesn't differ too much.


How can you pass a JavaScript value into a PHP file?

JavaScript lives in the browser, PHP lives on the server.To pass a value from JavaScript to a PHP page, you can eitherdo an HTML form submituse AJAXIn both cases, the value is sent to the server and you write your PHP to handle it and send a response.The important thing is that the JavaScript value won't be available in PHP when you first generate the page, creating the page and handling the value submitted from the browser are two distinct steps.


How do you create a text editor in PHP?

Well it got nothing to do with PHP, you going to need JavaScript to do that :)


What is the meaning of the name Ajax?

AJAX stands for Asynchronous JavaScript and XML.


How can you use a JavaScript variable in the PHP isset function?

You can't actually do that. There is no direct way to make JavaScript code talk to PHP code, as the two languages are interpreted in different locations. The PHP is interpreted by the server, and the JavaScript is interpreted by the client. This means it's easy enough to transfer data from PHP to JavaScript (by generating the JavaScript with the PHP), but not the other way around. If you're simply looking for a way to see if a JavaScript variable is set (from within the JavaScript itself), that can be done with a line like this one: if(myVariable !== undefined){ /* do stuff */} If you actually want to handle it on the PHP side, one way to do so would be to use additional PHP code when that happens. For example: <?php $jsVars = array(); ?> <script type="text/javascript"> var foo = 'bar'; <?php $jsVars['foo'] = 'bar';?> var yub = 'nub'; <?php $jsVars['yub'] = 'nub';?> </script> ... You can then check to see whether a certain variable has been set by seeing if it's in that array: <?php function jsIsset($varname){ global $jsVars; return array_key_exists($varname, $jsVars); } ?> This however, only works when the JavaScript is generated, not when it's interpreted by the client system. For example, imagine you have a variable that is defined by a JavaScript function that is called from an onclick event. By the time that event happens, the page has already been served and the PHP is done executing. If you want the JavaScript to tell the PHP that a variable is defined, you would need to do it through an AJAX request, which I believe is beyond the scope of this question.


How do you use the JavaScript confirm function in PHP?

It has to be done with Javascript. Though you could do something like this: