• 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.
  • Popular Now

  • Posts

    • I know Windows DHCP and DNS servers get teased a lot, but those services were at least created at a time when MS cared more than they do now, and they work mostly as expected. I actually use both in a multisite professional setting, not really because I love them, but because we use Active Directory and those services go hand-in-hand with it. A few times when I have needed to configure some more advanced features, I was worried Windows might not support them, but so far it has not let me down. I can only image the horror a Windows 11 era DHCP server would be, probably fewer options than the basic service on a Netgear router.
    • Since the article doesn't cover it: >Pinned Tabs allow you to always keep your favorite tabs open and just a click away. Pinned Tabs are small, can't be closed accidentally, and open automatically when you start Firefox. from https://support.mozilla.org/en...keep-favorite-websites-open
    • CapCut 6.4.0 (offline installer) by Razvan Serea CapCut is a versatile video editing app that offers a range of features such as multi-layer editing, keyframe animations, special effects, and more, to create professional-quality videos. With CapCut, users can edit and enhance their videos with a variety of tools such as filters, transitions, effects, and text overlays. CapCut's extensive library of pre-designed templates and visual effects also allows users to create unique and eye-catching videos in just a few clicks. Users can also adjust video speed, crop, and merge multiple clips, among other features. CapCut is available for both mobile devices and Windows, making it accessible for everyone. CapCut key features: User-friendly interface for easy video editing A wide range of editing tools, including trim, split, cut, and merge Music library with a wide range of tracks to choose from Customizable text and fonts to add captions and titles Multi-layer timeline for seamless editing and layering Filters and effects to enhance video quality and style A variety of transitions to choose from Multiple aspect ratio options for different platforms Green screen/chroma key for adding custom backgrounds Overlays and stickers to add to your videos Easy exporting to different video formats and resolutions Large library of pre-designed templates and visual effects Customizable video thumbnails for branding Keyframe animation to add movement to your video Speed adjustment for slow motion or time-lapse effects Customizable transitions between clips Reverse video playback for creative effects Voiceover recording and editing for narrating your video Color grading tools and much more... Download: CapCut 6.4.0 | 709.0 MB (Freeware) Links: CapCut Website | CapCut Screenshot | CapCut Online Editor Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • I love how everything is gold except the Trump name, which is usually gold. It's in red, but the US flag? No blue or red allowed. This is such a hack Photoshop job, I would have thought Jony Ive was behind it. But even he wouldn't show art this unfinished. Just this stupid.
    • >Unlimited talk time, messages, and internet As Captain Picard once said to the android nearby, "Data?"
  • Recent Achievements

    • Week One Done
      patrickft456 earned a badge
      Week One Done
    • One Month Later
      patrickft456 earned a badge
      One Month Later
    • One Month Later
      Jdoe25 earned a badge
      One Month Later
    • Explorer
      Legend20 went up a rank
      Explorer
    • One Month Later
      jezzzy earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      640
    2. 2
      ATLien_0
      279
    3. 3
      +FloatingFatMan
      170
    4. 4
      Michael Scrip
      156
    5. 5
      Steven P.
      131
  • Tell a friend

    Love Neowin? Tell a friend!