• 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

    • For anyone looking for a lightweight formatting-free text editor, I recommend Notepad3.
    • This looks really dumb, especially if it costs $100+. Noone who cares about using a flight yoke would touch that thing, people who don't care are probably fine using the analog sticks on their controller, so who is it for?
    • A) "they shouldn't be making money off of those [free videos]"?? That is literally their business model, making money off videos that users post...if you don't feel like that should be allowed, then are you saying YouTube shouldn't exist. B) Yes, the example I gave is a net-negative transaction. If YouTube makes money from others who are following their rules, it doesn't change the fact that the person using an ad-blocker is costing them money. C) YouTube has always operated at a loss...kind of invalidates your entire argument. As I always say, I don't care what you do, I will not even say you are wrong for doing it. That is purely your choice. Just be honest enough to say something like "Google is rich, I honestly don't care." Perfectly fine reason. Don't act like there is some imagined justification for why it isn't breaking the rules.
    • You can now present content from your camera feed in Google Meet by David Uzondu Google has a new feature rolling out for Google Meet that lets you directly present video from an external camera feed right into your meetings. This means if you have a document camera for showing physical papers, a dedicated external camera for a better angle, or even output from a video production tool, you can now pipe that into Meet as a presentation source. This new option supports video up to 1080p at 30FPS. This "present from camera" function offers a more integrated way to handle certain video inputs compared to some existing workarounds. For instance, it might prove less complicated than a setup with OBS Studio where you arrange your various video sources into scenes, activate the virtual camera output, and then navigate Google Meet's settings to specifically choose "OBS Virtual Camera" as your video input before you can even start presenting that customized feed. Alongside this camera presentation feature, Google's announcement also mentioned several improvements to the general screen sharing experience in Meet. Initiating any type of screen share is faster now, and video quality during screen sharing has also been sharpened, with better handling of dynamic content like scrolling text or embedded videos. To reduce interruptions, if a second presenter stops sharing their screen, any previous presentation will now automatically resume. For those wondering when they can get their hands on this, the rollout for the camera presentation feature and these screen sharing enhancements has begun for Rapid Release domains. Users on Scheduled Release domains will start seeing it from June 11, 2025. Google notes that it could take up to 15 days for these features to be visible to all eligible users. Most Google Workspace accounts, including Business Standard and Plus, various Enterprise and Education tiers, and Workspace Individual subscribers, will have access. This new presentation option joins other recent Google Workspace enhancements. For instance, Gemini in Google Drive can now summarize changes to your files, offering a quick way to get updated on what you missed in documents since you last opened them.
  • Recent Achievements

    • First Post
      James courage Tabla earned a badge
      First Post
    • Reacting Well
      James courage Tabla earned a badge
      Reacting Well
    • Apprentice
      DarkShrunken went up a rank
      Apprentice
    • Dedicated
      CHUNWEI earned a badge
      Dedicated
    • Collaborator
      DarkShrunken earned a badge
      Collaborator
  • Popular Contributors

    1. 1
      +primortal
      382
    2. 2
      +FloatingFatMan
      177
    3. 3
      ATLien_0
      174
    4. 4
      snowy owl
      169
    5. 5
      Xenon
      134
  • Tell a friend

    Love Neowin? Tell a friend!