• 0

PHP,Javascript questions


Question

11 answers to this question

Recommended Posts

  • 0

-how to submit a form with JavaScript towards php

- difference between print and echo (kinda trolling)

-should user submitted values always be validated trough php even if they're already validated trough JavaScript?

  • 0

We have a short test for candidates where I work, we have them create a simple user registration system using ajax. It should store users in the database, check to make sure the username and email are unique, hashing the password. Returns error and success messages via ajax callbacks. They ought to be able to accomplish this in well under an hour especially if they use jQuery or any other JS library.

 

It gives a pretty good idea on how familiar they are with coding conventions regarding user input, hashing passwords, and of course a pretty basic implementation of ajax. You'd be shocked at how many people can't accomplish this.

  • 0
  On 09/10/2013 at 19:42, Seahorsepip said:

-how to submit a form with JavaScript towards php

- difference between print and echo (kinda trolling)

-should user submitted values always be validated trough php even if they're already validated trough JavaScript?

dont really want javascript to submit a form is pointless IMO, Jquery is nicer, especially for real time :3..

also I have 7 years experience and I forget the difference between print and echo xD for most part...I also feel like I should answer the third one ...yes...because they may have JS turned off :P plus php is private I hate people seeing my regular expression *shifty eyes*

______________________

 

you want to ask basic programming questions and logic, if you want a PHP developer he needs to be an all rounder and understand programming...

1, what is the difference between a class and a function.

2, how does an object and an array compare, and how do they differ.

3. give him a but of code and ask him to write in varible names (leave just a $ and a aproprate space for him to feel them out)

PHP specific:

1, if written correctly what do you not need to use when posting data to a PDO function/statement...

2, get him to design a small database for customers (yes its MySQL but there is no point hiring a PHP developer who cant MySQL) and get him to write a bit of code which calls all the information (using a function) and displays them in a basic html table (basic because you are testing his php skills and logic not his UI developer skills, but he still needs to know basic html)

  • 0
  On 13/10/2013 at 20:19, SPEhosting said:

dont really want javascript to submit a form is pointless IMO, Jquery is nicer, especially for real time :3..

also I have 7 years experience and I forget the difference between print and echo xD for most part...I also feel like I should answer the third one ...yes...because they may have JS turned off :p plus php is private I hate people seeing my regular expression *shifty eyes*

______________________

 

you want to ask basic programming questions and logic, if you want a PHP developer he needs to be an all rounder and understand programming...

1, what is the difference between a class and a function.

2, how does an object and an array compare, and how do they differ.

3. give him a but of code and ask him to write in varible names (leave just a $ and a aproprate space for him to feel them out)

PHP specific:

1, if written correctly what do you not need to use when posting data to a PDO function/statement...

2, get him to design a small database for customers (yes its MySQL but there is no point hiring a PHP developer who cant MySQL) and get him to write a bit of code which calls all the information (using a function) and displays them in a basic html table (basic because you are testing his php skills and logic not his UI developer skills, but he still needs to know basic html)

Eh jquery != ajax

Ajax is a form if javascript not a form of jquery :p

 

THe question was just meant to see if they even know about ajax ^^

 

 

Also I hope PDO isn't too much used, it's nice but in a lot of cases slower then mysqli ;)

  • 0
  On 15/10/2013 at 12:21, Seahorsepip said:

Eh jquery != ajax

Ajax is a form if javascript not a form of jquery :p

 

THe question was just meant to see if they even know about ajax ^^

 

 

Also I hope PDO isn't too much used, it's nice but in a lot of cases slower then mysqli ;)

lol what? confused to where i mentioned ajax lol but yes i derped with the Jquery ... and pdo is just nicer :p its easier to read, debug and most of the software I build doesnt need to handle 100000s of users a minute its mostly online management systems for companies :3

  • 0
  On 15/10/2013 at 12:21, Seahorsepip said:

Eh jquery != ajax

Ajax is a form if javascript not a form of jquery :p

 

That is so not true. AJAX is a development technique for creating asynchronous requests to and from a server. In Javascript you use XMLHttpRequest object to do that and in jQuery you use jQuery.ajax() function.

 

  On 15/10/2013 at 12:21, Seahorsepip said:

Also I hope PDO isn't too much used, it's nice but in a lot of cases slower then mysqli ;)

 

Also, can't agree with this one. In some cases it might be slower (not a lot), but in exchange you get about 12 different database drivers so if you ever decide to change db engine in your application you just need to change the driver.

 

  On 13/10/2013 at 20:19, SPEhosting said:

...I also feel like I should answer the third one ...yes...because they may have JS turned off :p plus php is private I hate people seeing my regular expression *shifty eyes*

 

You should always validate data on a server-side. Not because JS might be turned off but because it's client-side validation and it can be tampered with before sending it to a server. Having 7 years of experience you should know that. :-)

 

  On 13/10/2013 at 20:19, SPEhosting said:
1, what is the difference between a class and a function.

 

I would ask what is the difference between a method and a function.

 

  On 13/10/2013 at 20:19, SPEhosting said:
3. give him a but of code and ask him to write in varible names (leave just a $ and a aproprate space for him to feel them out)

 

WHY... I mean why? ;-)

 

  On 13/10/2013 at 17:01, mollick2 said:

We have a short test for candidates where I work, we have them create a simple user registration system using ajax. It should store users in the database, check to make sure the username and email are unique, hashing the password. Returns error and success messages via ajax callbacks. They ought to be able to accomplish this in well under an hour especially if they use jQuery or any other JS library.

 

It gives a pretty good idea on how familiar they are with coding conventions regarding user input, hashing passwords, and of course a pretty basic implementation of ajax. You'd be shocked at how many people can't accomplish this.

 

Yep. This should be good but it might be not enough for a guy with seven years of experience.

  • 0

Q-01 .    What is the output of the following piece of code?

<?php
define('FOO', 10);
$array = array(10 => FOO, "FOO" => 20);
print $array[$array[FOO]] * $array["FOO"];
?>




Q-02 .    What is the best way to ensure that a user-defined function is always passed an object as its single parameter?

?    function myfunction(stdClass $a)
?    function myfunction($a = stdClass)
?    Use is_object() within the function
?    There is no way to ensure the parameter will be an object
?    function myfunction(Object $a)




Q-03 .    Which operator is used to test if two values are identical in every way?




 
Q-04 .    What would you replace ??????? with, below, to make the string ?Hello, World!? be displayed?

<?php
function myfunction() {
???????
print $string;
}
myfunction("Hello, World!");
?>

?    There is no way to do this
?    $string = $argv[1];
?    $string = $_ARGV[0];
?    list($string) = func_get_args();
?    $string = get_function_args()




Q-05 .    For an arbitrary string $mystring, which of the following checks will correctly determine if the string PHP exists within it?

?    if(strpos($mystring, "PHP") !== false)
?    if(!strpos($mystring,"PHP"))
?    if(strpos($mystring, "PHP") === true)
?    if(strloc($mystring, "PHP") == true)
?    if(strloc($mystring, "PHP") === false)




Q-06 .    Which function would you use to add an element to the beginning of an array?

?    array_shift()
?    array_push();
?    $array[0] = "value";
?    array_unshift()
?    array_pop();


SQL

Salesperson
ID    Name    Age    Salary
1    Nik    61    140,000
2    Paul    34    44,000
5    Pete    34    40,000
7    Jason    41    52,000
8    Dave    57    115,000
11    Graeme    38    38,000

Customer
ID    Name    City    Industry
4    Samsonic    London    J
6    Pansung    Birmingham    J
7    Technoshiba    Manchester    B
9    Toshnics    Manchester    B

Orders
ID    Date    Customer_ID    Salesperson_ID    Amount
1    08/02/1996    4    2    540
2    01/30/1999    4    8    1,800
3    07/14/1995    9    1    460
4    01/29/1998    7    2    2,400
5    02/03/1998    6    7    600
6    03/02/1998    6    7    720
7    05/06/1998    9    7    150

Q-07 .    With reference to the above data, express an SQL statement that will give the names of all salespeople who have an order with Samsonic?








Q-08 .    With reference to the above data, express an SQL statement that will give the names and order counts of all salespeople with 2 or more orders?







Q-09 .    With reference to the above data, write an SQL stored procedure named ?GetRegionalTopEarners? that will take input parameters of CityName and MinOrderVal, listing all salespeople and their order value totals who have order totals higher than the given value ?



JavaScript
Q-10 .    Using jQuery (assuming already loaded) write a script to enumerate through a page?s hyperlinks, add them to an array and list them at the bottom of the page?
 

  • Like 1
  • 0
  On 15/10/2013 at 13:48, ghostrider86 said:

That is so not true. AJAX is a development technique for creating asynchronous requests to and from a server. In Javascript you use XMLHttpRequest object to do that and in jQuery you use jQuery.ajax() function.

 

 

Also, can't agree with this one. In some cases it might be slower (not a lot), but in exchange you get about 12 different database drivers so if you ever decide to change db engine in your application you just need to change the driver.

 

 

You should always validate data on a server-side. Not because JS might be turned off but because it's client-side validation and it can be tampered with before sending it to a server. Having 7 years of experience you should know that. :-)

 

 

I would ask what is the difference between a method and a function.

 

 

WHY... I mean why? ;-)

 

 

Yep. This should be good but it might be not enough for a guy with seven years of experience.

jquery ajax function is just a function build on XMLHttpRequest it's not like jquery is a whole different piece of code from javascript it just simplifies it...

And yes PDO is way easier to use since it has works way better with multiple databases but it's kinda too overdone to use it for just a website that uses mysqli ony :P

  • 0
  On 15/10/2013 at 13:48, ghostrider86 said:

That is so not true. AJAX is a development technique for creating asynchronous requests to and from a server. In Javascript you use XMLHttpRequest object to do that and in jQuery you use jQuery.ajax() function.

 

 

Also, can't agree with this one. In some cases it might be slower (not a lot), but in exchange you get about 12 different database drivers so if you ever decide to change db engine in your application you just need to change the driver.

 

 

You should always validate data on a server-side. Not because JS might be turned off but because it's client-side validation and it can be tampered with before sending it to a server. Having 7 years of experience you should know that. :-)

 

well yea but that is what I implied :P even easier to tamper with thanks to google chromes developer tools :P I "hack" my own sites all the time... best thing is tampering with hiden form data 

  • 0

 

  On 15/10/2013 at 13:48, ghostrider86 said:

 

 

 

WHY... I mean why? ;-)

 

 

 

 

lol simple... naming :P you want to make sure someone has some kind of consistency with their code... along with common sense... I would get annoyed if my employees wrote $var1 .... $var2.... $var3.... when it could have been... $fullName....$subTotal...$nameOfPetDog

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • The Radeon RX 9060 XT is 5% slower than the GeForce RTX 5060 Ti, but the GeForce RTX 5060 Ti is 23% more expensive, at least when comparing MSRPs.
    • I would love to see Musk's face! 🤣🤣🤣
    • I think each AI option has their ups and downs. For Copilot, I find it more personable in how it talks compared to GPT & Gemini. I also appreciate the open ended questions it often provides at the end of its responses to keep the conversation going.
    • Microsoft offers free access to AI video creation with Bing Video Creator by Pradeep Viswanathan Two years ago, Bing Image Creator became one of the first major online services that allowed users to create images from text using OpenAI’s DALL-E model. Today, Microsoft is introducing Bing Video Creator, powered by OpenAI’s Sora, allowing users to create videos with text prompts. Despite announcing Sora last year, OpenAI has not been able to expand its availability to millions of ChatGPT users due to huge AI infrastructure requirements. It is still only available to ChatGPT Pro subscription users, which costs about $200 per month. Recently, Google announced its Veo 3 video generation model, which performs significantly better than OpenAI’s Sora, to all Gemini paid subscribers, making video generation accessible to even Gemini Pro subscribers, which costs just $20 per month. Now, Microsoft is democratizing access to video generation models by making Bing Video Creator free for all Bing users. Bing Video Creator is rolling out today globally (excluding China and Russia) on the Bing Mobile App, and it will be coming soon to the Bing desktop experience within Copilot Search. Bing Video Creator users will have the ability to choose between Fast and Standard generation speeds. Each user will have 10 Fast creations; following that, users can redeem 100 Microsoft Rewards points for each Fast creation or continue with Standard creation speeds. Once you have downloaded the Bing mobile app, here’s how you can access the Video Creator feature: Open Video Creator within the Bing Mobile app by clicking on the menu in the bottom right corner and selecting “Video Creator.” Just type in a text description of the video you want to create in the prompt box. Once the prompt text is ready, just tap “Create.” Or you can also just type directly into the Bing mobile app search bar "Create a video of..." to create a video. You’ll receive a notification when your video is ready to view. If required, you can also download the video or share it via social media or email. You will also have the ability to copy a direct link to the video for easy sharing elsewhere. Microsoft will be storing the generated videos for up to 90 days in your account for easy access later. Microsoft noted that the Bing Video Creator videos are 5 seconds long and can be created only in 9:16 format for now. Microsoft will be adding the 16:9 format soon. When you are waiting for your video to be created, you can also queue up another two videos. Once one of the slots becomes available, you can add another one to the queue. When Bing Video Creator becomes available on desktop, you can visit Bing.com/create for both image and video creation needs.
  • Recent Achievements

    • Week One Done
      Nullun earned a badge
      Week One Done
    • First Post
      sultangris earned a badge
      First Post
    • Reacting Well
      sultangris earned a badge
      Reacting Well
    • First Post
      ClarkB earned a badge
      First Post
    • Week One Done
      Epaminombas earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      150
    2. 2
      ATLien_0
      122
    3. 3
      Xenon
      121
    4. 4
      snowy owl
      99
    5. 5
      +Edouard
      95
  • Tell a friend

    Love Neowin? Tell a friend!