• 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

    • Microsoft's "Athena" AI: A blueprint for your own dev team's productivity boost by Paul Hill Last month, Microsoft made many developer-oriented announcements at its annual BUILD conference. One of the tools that it announced at the time was called Athena, an artificial intelligence agent that lives in Microsoft Teams and aims to speed up product development processes. Now, however, Microsoft has released the blueprint of Athena so anyone can begin implementing a similar helper for their work. Rather than just another chatbot, Athena is a deeply integrated agent accessible through Teams that helps to connect people, tools, and data throughout the product development process. Athena is smart enough to work out what needs to happen next and helps team members get it done without having to go to different applications - Athena controls it all from Teams and you just have to communicate in natural language. Athena can be embedded in several developer workflows including Teams, Azure DevOps, and GitHub. Perhaps the greatest thing about Athena is that it’s not a new product being sold by Microsoft, but rather a methodology and open-source template (Dex) that organizations or individuals can take to build their own AI agents, allowing for more customization. To get started with Athena, you'll want to set up the Dex agent. Microsoft has also published a breakout session video about Athena so you can take a deeper dive. Who it affects, and how The primary beneficiaries of Microsoft’s decision to release Athena open source are engineering teams everywhere who will be freed from boring, repetitive tasks such as pull request (PR) reviews, work item management, and security checks. This will let them get on with coding new features and innovating - something that Microsoft has been pushing hard for since the start of the latest AI revolution. For product managers and engineering leaders, Athena also looks set to be incredibly useful as they will get better real-time visibility into the status of projects, if a release is truly ready for launch, and to ensure the team is aligned. Organizations from small to large will be able to benefit from using Athena. Due to its open-source nature, Athena can be tailored to meet specific development processes. This could unlock faster delivery cycles and improve code quality across the board. Why it's happening Athena is already being used internally at Microsoft by over 2,000 of its engineers. The Redmond giant explained that this has led to “measurable gains” in speed, quality, and focus. Aside from faster review cycles for developers, Athena is also surfacing release-blocking bugs earlier, enabling the consistent completion of security and privacy workflows, and providing quicker health assessments so that teams can gauge the overall health of their software delivery. By handling all these more boring tasks, Athena can free up developers to build more features into their projects. It also has the potential to speed up delivery times so that end users can use the new software faster, and with potentially less bugs. We often hear the term “democratization” in tech, a process that makes technologies more accessible and affordable. According to this definition, Microsoft’s release of Athena delivers on democratizing AI for developers as its open source and allows people to integrate AI Into their workflows, without starting from scratch. The move also aligns with Microsoft's AI strategy, that is, putting it all throughout its products. Copilot is probably the most notorious for its omnipresence in essentially every Microsoft product including Windows and Edge. Unlike Copilot, developers get a bit more freedom with Athena, but it’s still tied up with Microsoft products, namely Teams and GitHub. Caveats and what to watch for While it’s great that Microsoft is making its Athena blueprint accessible, one issue is that developers may still find it a bit complex to implement as there are still specific customizations organizations will want to make. Additionally, this solution involves a more involved setup process as outlined in the GitHub README. Another thing organizations should be wary about is data privacy and security implications when it comes to integrating with sensitive internal systems. Organizations that are working on secretive projects probably wouldn’t want to use Athena as this could put sensitive code in the hands of third parties. It’s not only technical issues that need considering either, there is also the human element. Some people may have concerns about AI hallucinating or ethical concerns around job security that could hurt adoption. To this end, Microsoft has reaffirmed that Athena is supposed to assist teams only, not replace team members. While Athena can be extremely useful, as shown by the results internally at Microsoft, human oversight and judgment will still be vital. Complex decision and creative problem-solving in development are some areas where a human still needs to be involved. Source: Microsoft
    • How could it not be optional? ChatGPT isn't going to guess people's credentials :P
    • Mmmm, spread too thin into 2 quite different things
    • Only good thing shown at the showcase and it's not even an exclusive. And people keep saying that Xbox has no games 😅 Microsoft is going to wipe the floor with Sony this weekend.
    • flight? Maybe if they call it an arcade stick that'll help.
  • 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
      176
    3. 3
      ATLien_0
      174
    4. 4
      snowy owl
      169
    5. 5
      Xenon
      133
  • Tell a friend

    Love Neowin? Tell a friend!