PHP and Jquery Interview Questions & Answers

5 avg. rating (100% score) - 1 votes

PHP and Jquery Interview Questions & Answers

Experienced in PHP and Jquery? PHP and Jquery both are combined to form a powerful language. PHP script file has Jquery in HTML. Jquery is although not a scripting language but it is JavaScript code. The JS Library can be used to traverse HTML document and also for interactions with Ajax to web development. Even though many other jobs are present, PHP and Jquery job is unique. Good hands on knowledge on these concepts will put you ahead in interview. Every where we can find job opportunities for this position. Wisdomjobs has interview questions which are exclusively designed for employees to assist them in clearing interviews. PHP and Jquery interview questions are useful for employees who are good at PHP and Jquery technology.

PHP And Jquery Interview Questions

PHP and Jquery Interview Questions
    1. Question 1. What Is J-query?

      Answer :

      JQuery is a light weight JavaScript library which provides fast and easy way of HTML DOM traversing and manipulation, its event handling, its client side animations, etc. One of the greatest features of jQuery is that jQuery supports an efficient way to implement AJAX applications because of its light weight nature and make normalize and efficient web programs.

    2. Question 2. How To Use Jquery?

      Answer :

      jQuery can be easily used with other libraries so it should work out of the box with simple and complex JavaScript and Ajax.

    3. Question 3. What Distinguishes Php From Something Like Client Side Java Script?

      Answer :

      Java script applied on client side while in php code executed on server reviews side.

    4. Question 4. In Php How Can You Jump In To And Out Of "php Mode"?

      Answer :

      The Php code is enclosed in special Start < ? and end ? > tags that allow ingredients you to jump in to and out of “php mode”.

    5. Question 5. How To Use Jquery Library In Our Asp.net Project?

      Answer :

      Download the latest jQuery library from jQuery.com and include the reference to the jQuery library file in our ASPX page.

        <script  src="_scripts/jQuery-1.2.6.js" type="text/javascript"></script>
        <script language="javascript">
          $(document).ready(function() {
        alert('test');
        });
        </script> 

    6. Question 6. What Is Jquery Connect?

      Answer :

      It is a jquery plugin which enables us to connect a function to another function. It is like assigning a handler for another function. This situation happens when you are using any javascript plugins and you want to execute some function when ever some function is executed from the plugin. This we can solve using jquery connect function.

    7. Question 7. How To Use Jquery.connect?

      Answer :

      • download jquery.connect.js file.
      • include this file in your html file.
      • and use $.connect function to connect a function to another function.

    8. Question 8. Different Ways Of Using $.connect Function In Jquery?

      Answer :

      The syntax of connect function is
      $.connect(sourceObj/*object*/, sourceFunc/*string*/, callObj/*object*/, callFunc/*string or Func*/)

      • sourceObj(optional) is the object of the source function to which we want to connect.
      • sourceFunc is the function name to which we want to connect.
      • callObj(optional) is the object which we want to use for the handler function.
      • callFunc is the function that we want to execute when sourceFunc is executed.

      Here sourceObj, callObj are optional for the global functions.
      suppose if your sourceFunc is global function then no need to pass the sourceObj or you can use null or self.
      suppose if your callObj is global function then no need to pass the callObj or you can use null or self.

    9. Question 9. Explain The Concepts Of "$ Function" In Jquery With An Example?

      Answer :

      The type of a function is "function".
      There are a lot of anonymous functions is jquery.

      $(document).ready(function() {});
      $("a").click(function() {});
      
      $.ajax({
      url: "someurl.php",
      success: function() {}
      }); 

    10. Question 10. Why Is Jquery Better Than Javascript?

      Answer :

      • jQuery is great library for developing ajax based application.
      • It helps the programmers to keep code simple and concise and reusable.
      • jQuery library simplifies the process of traversal of HTML DOM tree.
      • jQuery can also handle events, perform animation, and add the Ajax support in web applications.

    11. Question 11. Explain How Jquery Works?

      Answer :

        <html>
        <head>
        <script type="text/javascript"  src="jquery.js"></script>
        <script type="text/javascript">
        // You can write the code here 
        </script>
        </head>
        <body>
        <a  href="http://www.wisdomjobs.com/">WisdomJobs</a>
        </body>
        </html> 

    12. Question 12. When Can You Use Jquery?

      Answer :

      • jQuery can be used to for developing ajax based applications.
      • It can be used to keep the code simple, concise and reusable.
      • It simplifies the process of traversal of HTML DOM tree.
      • It can also handle events, perform animation, and add the ajax support in web applications.

    13. Question 13. What Is A Jquery ?

      Answer :

      It’s very simple but most valuable Question on jQuery means jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, animating, event handling, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. jQuery is build library for javascript no need to write your own functions or script jQuery all ready done for you.

    14. Question 14. Change The Url For A Hyperlink Using Jquery?

      Answer :

      There are three way to change the URL for a Hyperlink using jQuery.

      1. $("a").attr("href", "http://www.wisdomjobs.com/");
      2. $("a[href='http://www.wisdomjobs.com/']") .attr('href', 'http://wisdomjobs.com/');
      3. $("a[href^='http://wisdomjobs.com']").each(function(){ this.href = this.href.replace(/^http: / /  beta.wisdomjobs.com/, "http://wisdomjobs.com"); });

    15. Question 15. Check Or Uncheck All Checkboxes Using Jquery?

      Answer :

      There are different methods to check and uncheck the check boxes.
      suppose that you have checkboxes like that

      <input type=”checkbox” value=”1″ name=”Items” id=”Items1″ />
      <input type=”checkbox” value=”2″ name=”Items” id=”Items2″ />
      <input type=”checkbox” value=”3″ name=”Items” id=”Items3″ />
      <input type=”checkbox” value=”4″ name=”Items” id=”Items4″ />

      using attr() function.
      $(‘#checkall’).click(function(){
      $(“input[@name='Items']:checked”).attr(‘checked’,true);
      });
      $(‘#uncheckall’).click(function(){
      $(“input[@name='Items']:checked”).attr(‘checked’,false);});
      
      using attr() and removeAttr()funstions
      $(‘#checkall’).click(function(){
      $(“input[@name='Items']:checked”).attr(‘checked’,true);
      })
      $(‘#uncheckall’).click(function(){
      $(“input[@name='Items']:checked”).removeAttr(‘checked’);})
      

    16. Question 16. Fetch The Values Of Selected Checkbox Array Using Jquery?

      Answer :

      Suppose that below is checkbox array
      <input type=”checkbox” value=”1″ name=”Items[]“ id=”Items1″ />
      <input type=”checkbox” value=”2″ name=”Items[]“ id=”Items2″ />
      <input type=”checkbox” value=”3″ name=”Items[]“ id=”Items3″ />
      <input type=”checkbox” value=”1″ name=”Items[]“ id=”Items4″ />
      and we want the get the value of selected checkbox using jquery.
      then simple use below code.
      var selItems = new Array();
      $(input[@name='Items[]‘]:checked”).each(function() {selItems .push($(this).val());});
      Here selItems will take all selected value of checkbox.

    17. Question 17. How We Can Apply Css In Multiple Selectors In Jquery?

      Answer :

      Here to take effect is example to demonstrate
      $(“div,span,p.myClass”).css(“border”,”1px solid green”);
      the border will be apply in all div,span ,p.myClass class element.

    18. Question 18. How We Can Modify The Css Class In Jquery?

      Answer :

      Using css method we can modify class using jquery
      example:$(“.CssClass1.CssClass2″).css(“border”,”1px solid green”);
      CssClass1,CssClass2 will be modify to border 1px solid green.

    19. Question 19. How Can We Apply Css In Div Using Jquery?

      Answer :

      using css() method we can apply css in div element.
      example:
      $(“div”).css(“border”,”1px solid green”);

    20. Question 20. Get The Value Of Selected Option In Jquery?

      Answer :

        <select id="sel">
        <option value="1">Hi</option>
        <option value="2">Hello</option>
        <option value="3">Helloooooo</option>
        <option value="4">ok</option>
        <option value="5">Okey</option>
        </select>

      want to get  the  value of selected option, then use

         $("select#sel").val();

      or text of selected box, then use

      $("#seloption:selected").text();

    21. Question 21. Check/uncheck An Input In Jquery?

      Answer :

      Using two function, we can perform the operation.

      // Check #x
      $(“#checkboxid”).attr(“checked”, “checked”);
      // Uncheck #x
      $(“#checkboxid”).removeAttr(“checked”);

    22. Question 22. Disable/enable An Element In Jquery?

      Answer :

      // Disable #x
      $(“#x”).attr(“disabled”,”disabled”);
      // Enable #x
      $(“#x”).removeAttr(“disabled”);
      

    23. Question 23. What Are The Advantages Of Jquery?

      Answer :

      The advantages of using jQuery are:

      • JavaScript enhancement without the overhead of learning new syntax.
      • Ability to keep the code simple, clear, readable and reusable.
      • Eradication of the requirement of writing repetitious and complex loops and DOM scripting library calls.

    24. Question 24. Explain The Features Of Jquery?

      Answer :

      Features of jQuery are :

      • Effects and animations
      • Ajax
      • Extensibility
      • DOM element selections functions
      • Events
      • CSS manipulation
      • Utilities – such as browser version and the each function.
      • JavaScript Plugins
      • DOM traversal and modification.

    25. Question 25. How Can We Apply Css In Odd Childs Of Parent Node Using Jquery Library?

      Answer :

      $(”tr:odd”).css(”background-color”, “#bbbbff”);

    26. Question 26. How Can We Apply Css In Even Childs Of Parent Node Using Jquery Library?

      Answer :

      $(”tr:even”).css(”background-color”, “#bbbbff”);

    27. Question 27. How Can We Apply Css In Last Child Of Parent Using Jquery Library?

      Answer :

      $(”tr:last”).css({backgroundColor: ‘yellow’, fontWeight: ‘bolder’});

    28. Question 28. What Does A Special Set Of Tags Do In Php?

      Answer :

      The tags <?= and ?>  displayed  output directly to the web  browser.

    29. Question 29. How Can We Calculate The Similarity Between Two Strings?

      Answer :

      Using similar_text() get similarity between two strings.

      Return Values

      Returns the number of matching chars in both strings.
      example

       <?php
      $first =’php3′;
      $first =’php4′;
      echo  retail price similar_text ( $first, $second )  //3
      ?>

    30. Question 30. Return Ascii Value Of Character In Php?

      Answer :

      using ord() method we can get ASCII value of character in php.

       <?php
        $str = "n" style="color:  #007700;">;
        if (ord style="color: #0000bb;">$str) == 10) {
        echo "The first character of $str is a line feed.n";
        }
        ?> 

    31. Question 31. How Can I Execute A Php Script Using Command Line?

      Answer :

      Just run the PHP CLI (Command Line Interface) program and provide the PHP script file name as the command line argument. For example, “php myScript.php”, assuming “php” is the command to invoke the CLI program. Be aware that if your PHP script was written for the Web CGI interface, it may not execute properly in command line environment.

    32. Question 32. What Difference Between Require() And Require_once()?

      Answer :

      Require()
      The Require() is used to include a file, It create fatal error if file not found and terminate script.

      require_once()
      The require_once() to require() except PHP will check if the file has already been included, and if so, tricor online not include (require) it again.

    33. Question 33. What Does Dollar Sign ($) Means In Jquery?

      Answer :

      Dollar Sign is nothing but it's an alias for JQuery. Take a look at below jQuery code

      $(document).ready(function(){
      });

      Over here $ sign can be replaced with "jQuery " keyword.

      jQuery(document).ready(function(){
      });

    34. Question 34. Mac, Windows Or Linux? Why Do You Love This Platform While Using Jquery?

      Answer :

      I switched to Mac hardware around a year ago and I’m totally in love with it. All components work together nicely, and so far, I never had to return my Mac book Pro to the Apple Store because of an issue. However, I’m still using Windows through Parallels because OSX, while visually nice and stable, has fundamental usability flaws.
      One of these flaws is the Finder. I recently worked on the jQuery UI Selectables in the labs version, and once again saw that the Finder had great flaws when it comes down to selection. For instance, if you select multiple items and click on one of them, the multiple selection isn’t cleared. Also, my tools that I love for windows simply don’t have an alternative yet .

    35. Question 35. How Is Body Onload() Function Is Different From Document.ready() Function Used In Jquery?

      Answer :

      Document.ready() function is different from body onload() function because off 2 reasons.

      1. We can have more than one document.ready() function in a page where we can have only one onload function.
      2. Document.ready() function is called as soon as DOM is loaded where body.onload() function is called when everything gets loaded on the page that includes DOM, images and all associated resources of the page.

    36. Question 36. What Is Jquery Ui?

      Answer :

      JQuery UI is a library which is built on top of JQuery library. JQuery UI comes with cool widgets, effects and interaction mechanism.

    37. Question 37. Name Some Of The Methods Of Jquery Used To Provide Effects?

      Answer :

      Some of the common methods are :

      1. Show()
      2. Hide()
      3. Toggle()
      4. FadeIn()
      5. FadeOut().

    38. Question 38. What Are The Different Type Of Selectors In Jquery?

      Answer :

      There are 3 types of selectors in Jquery

      1. CSS Selector
      2. XPath Selector
      3. Custom Selector.

    39. Question 39. How Can You Select All Elements In A Page Using Jquery?

      Answer :

      To select all elements in a page, we can use all selectors, for that we need to use *(asterisk symbol).

      
        <script  language="javascript" type="text/javascript">
          $("*").css("border",  "2px dotted red"); 
        </script> 

    40. Question 40. Which Version Of Jquery File Should Be Used?

      Answer :

      In most of the recent releases so far, the core functionality of jQuery remains same however some more cool and better features are added. Ideally you should use the latest jQuery files available. By doing this you ensure that your earlier functionality will still work and you can use new features available as part of the new release.

    41. Question 41. What Are Selectors In Jquery Mean ?

      Answer :

      Generally in HTML, if we need to work with any control on a web page we need to find the control. For that we use document.getElementByID or document.getElementByName. But in jquery we do it using Selectors.
      Using this selectors we can select all the controls as well using a symbol (* )
      A sample code snippet can be of this form

      <script language="javascript" type="text/javascript">
      $("*").css("border", "10px red");
      </script>
      

    42. Question 42. Do We Need To Add The Jquery File Both At The Master Page And Content Page As Well?

      Answer :

      No, if the Jquery file has been added to the master page then we can access the content page directly without adding any reference to it.
      This can be done using this simple example
      <script type="text/javascript" src="jQuery-1.4.1-min.js"></script>

    43. Question 43. What Is The Advantage Of Using The Minified Version Of Jquery Rather Than Using The Conventional One?

      Answer :

      • The advantage of using a minified version of JQuery file is Efficiency of the web page increases.
      • The normal version jQuery-x.x.x.js has a file size of 178KB but the minified version jQuery.x.x.x-min.js has 76.7 KB.
      • The reduction in size makes the page to load more faster than you use a conventional jQuery file with 178KB.

    44. Question 44. What Is Cdn And How Jquery Is Related To It?

      Answer :

      CDN - It stands for Content Distribution Network or Content Delivery Network.
      Generally, a group of systems at various places connected to transfer data files between them to increase its bandwidth while accessing data. The typical architecture is designed in such a way that a client access a file copy from its nearest client rather than accessing it from a centralized server.
      So we can load this jQuery file from that CDN so that the efficiency of all the clients working under that network will be increased.
      Example :
      We can load jQuery from Google libraries API
      <script type="text/javascript" language="Javascript"
      src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>

    45. Question 45. Can We Select A Element Having A Specific Class In Jquery ?

      Answer :

      Yes, we can select an element with a specific class, we use the class selector.The class name must contain the prefix as "." (dot).

      <script language="javascript" type="text/javascript">
      $(".class1").css("border", "2px solid red");
      </script>

    46. Question 46. What Are Features Of Jquery Or What Can Be Done Using Jquery?

      Answer :

      Features of Jquery:

      1. One can easily provide effects and can do animations.
      2. Applying / Changing CSS.
      3. Cool plugins.
      4. Ajax support
      5. DOM selection events
      6. Event Handling.

    47. Question 47. What Are The Advantages Of Jquery ?

      Answer :

      There are many advantages with JQuery. Some of them are :

      • It is more like a JavaScript enhancement so there is no overhead in learning a new syntax.
      • It has the ability to keep the code simple, readable, clear and reusable.
      • It would eradicate the requirement for writing complex loops and DOM scripting library calls.

    48. Question 48. Why Jquery?

      Answer :

      jQuery is very compact and well written JavaScript code that increases the productivity of the developer by enabling them to achieve critical UI functionality by writing very less amount of code.
      It helps to

      • Improve the performance of the application
      • Develop most browser compatible web page
      • Implement UI related critical functionality without writing hundreds of lines of codes
      • Fast
      • Extensible – jQuery can be extended to implement customized behavior.

      Other advantages of jQuery are

      • No need to learn fresh new syntax's to use jQuery, knowing simple JavaScript syntax is enough.
      • Simple and Cleaner code, no need to write several lines of codes to achieve complex functionality.

    49. Question 49. What Is The Use Of Delegate() Method In Jquery?

      Answer :

      The delegate() method can be used in two ways.
      1) If you have a parent element, and you want to attach an event to each one of its child elements, this delegate() method is used.
      Ex:Un-ordered
      2) When an element is not available on the current page, this method is used.
      .live() method is also used for the same purpose but, delegate() method is a bit faster.

    50. Question 50. What Is The Name Of Jquery Method Used For An Asynchronous Http Request?

      Answer :

      jQuery.ajax().

Php And Jquery Tutorial

All Tutorials

All Practice Tests

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

PHP and Jquery Tutorial