• 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

    • Revo Uninstaller Free 2.6.0 by Razvan Serea Revo Uninstaller helps you to uninstall software and remove unwanted programs installed on your computer easily! Even if you have problems uninstalling and cannot uninstall them from "Windows Add or Remove Programs" control panel applet. With its advanced and fast algorithms, Revo Uninstaller analyzes an application's data before uninstall and scans for remnants after the uninstall of a program. After the program's regular uninstaller runs, you can remove additional unnecessary files, folders and registry keys that are usually left over on your computer. Revo Uninstaller offers you some simple, easy to use, but effective and powerful methods for uninstalling software like tracing the program during its installation. Revo Uninstaller has a very powerful feature called Forced Uninstall. Forced Uninstall is the best solution when you have to remove stubborn programs, partially installed programs, partially uninstalled programs, and programs not listed as installed at all! To remove a program completely, and without leaving a trace, you can monitor all system changes made during its installation, and then use that information to uninstall it with one click only – simple and easy! Revo Uninstaller is a much faster and more powerful alternative to "Windows Add or Remove Programs" applet! It has very powerful features to uninstall and remove programs. No more stubborn programs No more installation errors No more upgrade problems Remove programs easily Revo Uninstaller Free 2.6.0 changelog: Improved – Scanning algorithms for leftovers Fixed minor bugs Updated language files Download: Revo Uninstaller Free 2.6.0 | Portable ~10.0 MB (Freeware) View: Revo Uninstaller Website | Revo Uninstaller Pro | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • I do agree with your point on the lack of ability to reach a human support agent, it's highly frustrating and sadly not uncommon these days. 100% - if a company breaches a SLA, that's not acceptable, but if you breach their ToS then the SLA is invalidated. Why the guy was locked out? - who knows, its looks like it's breach of ToS, but who knows, maybe it's an error on Microsoft's side in this instance, maybe it's an accident, maybe it's a flagrant breach - pointless speculating. However the point here is by uploading all your data to a single point you have backed yourself into a corner where you don't have a recovery plan and that is 100% on you. If you have all your data on hard disk and it fails - do you blame the manufacturer for the data loss? What if the provider goes bust What if you forget to update a payment method and the account is terminated because you miss the email because you're busy, change the address, whatever What if the provider has a catastrophic failure (unlikely with the bigger players, but nothing is impossible) Point being however you store data - be it cloud or locally, if you only have one copy it should be viewed as data at risk, and you are the one who must manage the risk.
    • Rematch, Warcraft, another Call of Duty, FBC: Firebreak, and more hit Xbox Game Pass by Pulasthi Ariyasinghe Microsoft has unveiled the games that will be available to Xbox Game Pass subscribers in the second half of June. The latest wave touts several more games from the coffers of Activision Blizzard, including the three remastered Warcraft games and the 2017-released Call of Duty: WWII. Three day-one drops are a part of this wave. This includes Remedy Entertainment's first multiplayer-focused co-op entry, FBC: Firebreak, the hugely anticipated soccer game from Sifu developers, Rematch, and the indie roguelike Lost in Random: The Eternal Die. Here are all the games announced for Game Pass today and their arrival dates: FBC: Firebreak (Cloud, PC, and Xbox Series X|S) – Available today Crash Bandicoot 4: It’s About Time (Console and PC) – Available today Lost in Random: The Eternal Die (Cloud, PC, and Xbox Series X|S) – Available today Star Trucker (Xbox Series X|S) – June 18 Wildfrost (Console) – June 18 Rematch (Cloud, PC, and Xbox Series X|S) – June 19 Volcano Princess (Cloud, Console, and PC) – June 24 Against the Storm (Cloud and Console) – June 26 Warcraft I: Remastered (PC) – June 26 Warcraft II: Remastered (PC) – June 26 Warcraft III: Reforged (PC) – June 26 Call of Duty: WWII (Console and PC) – June 30 Little Nightmares II (Cloud, Console, and PC) – July 1 Rise of the Tomb Raider (Cloud, Console, and PC) – July 1 Just as new games arrive, six will be leaving the Game Pass programs on June 30. These are Arcade Paradise, Journey to the Savage Planet, My Friend Peppa Pig, Robin Hood: Sherwood Builders, SteamWorld Dig, and SteamWorld Dig 2 across both PC and Xbox consoles. With June reveals out of the way, expect the next Game Pass announcement to arrive in early July, revealing what's coming in the first half of the new month. Don't forget that the Xbox Games Showcase also revealed more titles for Game Pass like The Outer Worlds 2, Grounded 2, Black Ops 7, and At Fate's End.
    • context menu before it was instantly, now you need to click twice and the old context menu sometimes have to load
    • Is NAD a legitimate court? Nope, it's part of the BBB. So they can allege whatever they want. Guilt is the result of being convicted by an actual recognized legitimate court. Just sayin.
  • Recent Achievements

    • Week One Done
      Rhydderch earned a badge
      Week One Done
    • Experienced
      dismuter went up a rank
      Experienced
    • One Month Later
      mevinyavin earned a badge
      One Month Later
    • Week One Done
      rozermack875 earned a badge
      Week One Done
    • Week One Done
      oneworldtechnologies earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      698
    2. 2
      ATLien_0
      272
    3. 3
      Michael Scrip
      214
    4. 4
      +FloatingFatMan
      186
    5. 5
      Steven P.
      144
  • Tell a friend

    Love Neowin? Tell a friend!