LinkedIn is a professional networking platform used by individuals across various industries, including web development, where PHP is commonly utilized. Therefore, you can leverage LinkedIn to connect with other professionals in the PHP development community, join relevant groups, participate in discussions, share knowledge, and explore job opportunities related to PHP development.
Here’s how you can utilize LinkedIn for PHP development:
- Profile Optimization: If you’re a PHP developer or have experience working with PHP, ensure that your LinkedIn profile highlights your skills, experiences, and achievements related to PHP development. This will help you attract the attention of recruiters and potential employers seeking PHP talent.
- Networking: Connect with other professionals in the software development industry, including PHP developers, engineers, and enthusiasts. You can search for people with PHP expertise and send connection requests to expand your professional network.
- Groups: Join LinkedIn groups focused on PHP development, web development, and related topics. Participating in these groups allows you to engage in discussions, ask questions, and share insights with fellow PHP developers.
- Job Search: Use LinkedIn’s job search feature to find PHP development jobs and opportunities in companies that require PHP expertise. You can filter job listings based on location, experience level, industry, and other criteria to find relevant opportunities.
- Learning and Sharing: LinkedIn offers features such as LinkedIn Learning and publishing articles/posts. You can use these features to enhance your PHP skills by taking relevant courses and sharing your knowledge and experiences with the LinkedIn community.
LinkedIn PHP Exam Quiz Answers
Question 1: What does this code output?
- 1
- -1
- a parser errors
- 0
Question 2: Which is the most secure way to avoid storing a password in clear text in database?
- $encrypted = shal($password);
- $encrypted = crypt ($password, \$salt);
- $encrypted = md5($password);
- $encrypted = password_hash ($password, PASSWORD_DEFAULT);
Question 3: What does this script do?
- It makes sure the email address is a good and functioning address
- It makes an email safe to input into a database
- It assigns an email to a variable and then removes all illegal characters from the $email variable
- It verifies that an email address is well formed.
Question 4: In the following script, which line(s) will cause an error(s)?
- Line 6 will cause an error because you can’t reassign a new value to a variable that has already been set.
- Line 7 and 8 will cause an error. Line 7 has whitespace in $will i work and should be $will_i_work. Line 8 cannot start with a number because it is a variable.
- Line 5 will cause an error because some_string should be someString.
- Line 3 and 4 will cause an error because a variable cannot start with an underscore (_).
Question 5: In a conditional statement, you want to execute the code only if both values are true. Which comparison operator should you use?
- ||
- &
- <=>
- &&
Question 6: All variables in PHP start with which symbol?
- &
- %
- _
- $
Question 7: What is a key difference between GET and POST?
- GET is used with the HTTP protocol. POST is used with HTTPS.
- GET displays the submitted data as part of the URL. During POST, this information is not shown, as it’s encoded in the request body.
- GET is intended for changing the server state and it carries more data than POST.
- GET is more secure than POST and should be used for sensitive information.
Question 8: The **_ operator is useful for sorting operations. It compares two values and returns an integer less than, equal to, or greater than 0 depending on whether on whether the value on the _**is less than, equal to, or greater than the other.
- greater-than; right
- spaceship; left
- equality; right
- comparison; left
Question 9: Which are valid PHP error handling keywords?
- try, throw, catch, callable
- try, yield, catch, finally
- yield, throw, catch, finally
- try, throw, catch, finally
Question 10: Which value equates to true?
- 0
- NULL
- ”
- -1
Question 11: What is missing from this code, which is supposed to create a test cookie?
- The $_REQUEST is missing.
- The $_COOKIES array is missing.
- The cookie session is missing.
- The call to setcookie () is missing.
Question 12: What is the value of $total in this calculation?
- 44
- 138
- 126
- 100
Question 13: What is the purpose of adding a lowercase “u” as a modifier after the final delimiter in a Perl-compatible regular expression?
- It makes the dot metacharacter match anything, including newline characters.
- It makes the pattern match uppercase letters.
- Both the pattern and subject string are treated as UTF-8.
- It inverts the greediness of the quantifiers in the pattern so they are not greedy by default.
Question 14: Which code snippet uses the correct syntax for creating an instance of the Pet class?
- $dog = new Pet;
- all of these answers
- $horse = (new Pet);
- $cat = new Pet ();
Question 15: What is the best way to explain what this script does?
- This script times out the session for my username.
- Cookies are starting to be stored as a result of this script.
- This script validates the username and password.
- This script is on a page that requires the user to be logged in. It checks to see if the user has a valid session.
Question 16: Which is the correct format for adding a comment to a PHP script?
- all of these answers
- #This is a comment
- /* This is a comment /
- // This is a comment
Question 17: PHP supports multiple types of loops. If you wanted to loop through a block of code if and as long a specified condition is true, which type of loop would you use?
- for
- do-while
- while
- foreach
Question 18: The ignore_user_abort () function sets whether a client disconnect should abort a script execution. In what scenario would you, as a web developer, use this function?
- You would use it to stop a user from clicking the back button if they decide not to view as a result of a click.
- You would use this function if you have some important processing to do and you do not want to stop it, even if your users click Cancel.
- You would use this function if you wanted to abort the script for all logged-in users, not just the one who disconnected.
- You would use this function if you want a PHP script to run forever.
Question 19: The PHP function array_reduce () takes a callback function that accepts a value carried over each iteration and the current item in the array, and reduces an array to a single value. Which code sample will sum and output the values in the provided array?
- 1 <?php
2 echo arrays_reduce ([1, 2, 5, 10, 11], function ($item, $carry) {
3 $carry = $carry + \$item;
4});
5?>
- 1 <?php
2 echo arrays_reduce ([1, 2, 5, 10, 11], function ($carry, $item) {
3 returns $carry = $item + \$item;
4});
5?>
- 1 <?php
2 arrays_reduce ([11 2, 5, 10, 11], function ($item, $carry) {
3 echoes $carry + $item;
4});
5?>
- 1 <?php
2 echo arrays_reduce ([1, 2, 5, 10, 11], function ($carry, $item) {
3 returns $carry += $item;
4});
5?>
Question 20: Which PHP script uses a constructor to display the string “Winter is almost over!”?
- 1 class MyClass {//Maybe
2 public function \_construct ()
3 {
4 echoes ‘Winter is almost over!’.” \n”;
5}
6}
7 \$userclass = new MyClass;
- 1 class MyClass {
2 public functions _construct ()
3 {
4 echoes ‘Winter is almost over!” \n”;
5}
6}
7 $userclass = new MyClass;
- 1 class MyClass {
2 public function \_construct ()
3 {
4 echoes ‘Winter is almost over!” \n”;
5}
6}
7 \$userclass = new MyClass;
- 1 class MyClass {
2 public functions _construct ()
3 {
4 echoes ‘Winter is almost over!’.” n”;
5}
6}
7 $userclass = MyClass;
Question 21: How might you troubleshoot a “call to undefined function” error?
- Make sure you have imported the file containing the function.
- Make sure you have spelled the function name correctly.
- all of these answers
- Make sure the function declaration is at an earlier point in the code than the function call.
Question 22: Which line could you NOT use to comment out “Space: the final frontier”?
- /_ Space: the final frontier _/
- / Space: the final frontier /
- #Space: the final frontier
- // Space: the final frontier
Question 23: What displays in a browser when the following code is written?
- The browser would display nothing due to a syntax error.
- The browser would display an error, since there are no parentheses around the string.
- The browser would display How much are the bananas?
- The browser would display an error, since there is no semicolon at the end of the echo command.
Question 24: Which operator would you use to find the remainder after division?
- /
- %
- //
- DIV
Question 25: What is the significance of the three dots in this function signature?
- It makes the function variadic, allowing it to accept as an argument an array containing an arbitrary number of values.
- It makes the function variadic, allowing it to accept an arbitrary number of arguments that are converted into an array inside the function.
- It temporarily disables the function while debugging other parts of the script.
- It’s a placeholder like a TO DO reminder that automatically triggers a notice when you run a script before completing the function definition.
Question 26: Assuming the Horse class exists, which is a valid example of inheritance in PHP?
- class Pegasus extends Horse {}
- class Alicorn imports Pegasus, Unicorn {}
- class Unicorn implements Horse {}
- class Horse inherits Unicorn {}
Question 27: Both triple === and double == can be used to **_ variables in php. If you want to hear that string “33” and the number 33 are equal, you would use ** . If you want to check if an array contains a particular string value at a particular index, you would use ___
- compare; doubles; triples
- compare; triples; doubles
- assign; triples; doubles
- assign; doubles; triples
Question 28: Your php page is unexpectedly rendering as totally blank. Which step will shed light on the problem?
- Add this code to the top of your script:ini_set(‘display_errors’,1);
- check the server error logged
- all of these answers
- make sure you are not missing any semicolons
Question 29: Which is the way to create an array of “seasons”?
- seasons=array (1=>’spring’, 2=>’summer’, 3=>’autumn’, 4=>’winter’,);
- $seasons=array (spring, summer, autumn, winter);
- $seasons=(‘spring’,’summer’,’autumn’,’winter’);
- $seasons=[‘spring’,’summer’,’autumn’,’winter’];
Question 30: Both self and this are keywords that can be used to refer to member variables of an enclosing class. The difference is that $this->member should be used for __ members and self: $ member should be used for __ members.
- private, public
- object, primitive
- non-static, static
- concrete, abstract
Question 31: What will this code print?
- euler3
- hypatia5
- hypatia3
- fibonacci4
Question 32: You are using the following code to find a users band, but it is returning false. Which step(s) would solve the problem?
- check if fav_band is included in the query string at the top of your browser
- all of the answers
- view the source of form and make sure there is an input field with the name ‘fav_band’
- print everything that has been transmitted in the request:print_r($_REQUEST);
Question 33: Which code would you use to print all the elements in an array called $cupcakes?
- all of the answers
- print_r($cupcakes);
- var_dump($cupcakes);
- foreach ($cupcakes as &$cupcake) echo $cupcake;
Question 34: What is the cause of ‘Cannot modify header information – headers already sent’?
- You are trying to modify a private value
- Semicolon missing
- Using a key on an array that does not exists
- Some html is being sent before a header () command that you are using for a redirect
Question 35: Which php control structure is used inside a loop to skip the rest of the current loops code and go back to the start of the loop for the next iteration
- else
- break
- return
- continue
Question 36: The php not operator is! Given the snippet, is there an output and what is it?
- there is an output ‘2 is an even number
- output ’21 is an odd number’
- no output. Syntax error do to missing semicolon at the end
- no output due to % in $num%2! =0
Question 37: You want to list the modules available in your PHP installation. What command should you run?
- php -h
- php info
- php -v
- php -m
Question 38: What is the value of ‘$result’ in this calculation? $result = 25 % 6;
- 4.167
- 1.5
- 4
- 1
Question 39: What is the job of the controller as a component in MVC?
- The controller handles data passed to it by the view, and also passes data to the view. It interprets data sent by the view and disperses that data to the appropriate models awaiting results to pass back to the view.
- The controller is a mechanism that allows you to create reusable code in languages such as PHP, where multiple inheritance is not supported.
- The controller presents content through the user interface, after communicating directly with the database.
- The controller handles specific tasks related to a specific area of functionality, handles business logic related to the results, and communicates directly with the database.
Question 40: Why does this code trigger an error? $string = ‘Shylock in a Shakespeare’s “Merchangt of Venice” demands his pound of flesh.’;
- Strings should always be wrapped in double quotes; and double quotes inside a string should be escaped by backslashes.
- All single and double quotes inside a string need to be escaped by backslashes to prevent a parse error.
- The opening and closing single quotes should be replaced by double quotes; and the apostrophe should be escaped by a backslash.
- The apostrophe needs to be escaped by a backslash to prevent it from being treated as the closing quote.
Question 41: A PDO object called $db has been set up to use for database operations, including user authentication. All user-related properties are set. The script line public function __construct(&$db) shows a constructor that initializes all user-related properties to ____ if no user has logged in. These parameters will be properly set by the login functions when a user logs in.
- NULL
- TRUE
- FALSE
- 0
Question 42: Assuming that $first_name and $family_name are valid strings, which statement is invalid?
- echo $first_name. ‘ ‘. $familiy_name;
- print $first_name, ‘‘, $familiy_name;
- print $first_name. ‘ ‘. $familiy_name;
- echo $first_name, ‘‘, $familiy_name;
Question 43: Which code snippet demonstrates encapsulation?
- class Cow extends Animal {
private $milk;
}
- class Cow {
public $milk;
}
$daisy = new Cow ();
$daisy->milk = “creamy”;
- class Cow {
public $milk;
function getMilk () {`
return $this->milk;
}
}
- class Cow {
private $milk;
public function getMilk () {
return $this->milk;
}
}
Question 44: The following XML document is in books.xml. Which code will output “Historical”?
- $books = simplexml_load_string(‘books.xml’); echo $books->book[0]->categories->category [1];
- $books = simplexml_load_file(‘books.xml’); echo $books->book[0]->categories->category [1];
- $books = SimpleXMLElement(‘books.xml’); echo $books->book[0]->categories->category [1];
- $books = SimpleXML(‘books.xml’); echo $books->book[0]->categories->category [1];
Question 45: Which command will extract the domain suffix (“com”) from the string $string = “https://cat-bounce.com”?
- sub ($string, -3)
- substr ($string, -3)
- substr ($string, 3)
- $string. substr (-3)
Question 46: Where is PHP code executed?
- in the client’s browser
- in the virtual machine
- in the memory of the computer viewing the webpage
- on a web server
Question 47: Which PHP variable name is invalid?
- $Double
- $double
- $_2times
- $2times
Question 48: What are the recommended settings in the PHP configuration file, php.ini, for a testing environment?
- report_errors = E_ALL
display_errors = On
- error_reporting = E_ALL
display_errors = On
- error_reporting = E_ALL & ~E_NOTICE
display_errors = Off
- error_reporting = E_ALL & ~E_NOTICE
display_errors = On
Question 49: What are getters and setters?
- Getters and setters ensure that if a data member is declared private, then it can be accessed only within the same function, not by an outside class
- Getters and setters are utility functions within PHP that allow loading from, and saving to, a database
- Getters and setters encapsulate the fields of a class by making them acccessible only through its private methods, and keep the values themselves public
- Getters and setters are methods used to declare or obtain the values of variables, usually private ones
Question 50: Why should you follow a PSR standard?
- because coding standards often vary between developers and companies
- because coding standards are monitored for compliance across developers and companies
- because there are mandatory coding standards among developers and companies
- if using certain platforms, because the PSR’s apply to those platforms only
Question 51: You are using the following code to decide if a button is clicked, but it is never returning true. Which step is most likely to shed light on the problem?
- Make sure the input field displaying the button is named ‘submit’
- Make sure you are not missing any semicolons
- Print everything in the session print_r($_SESSION);
- Look in the query string at the top of your browser to see if submit is assigned a value
Question 52: If you want to pass a formfield to another page when a button is clicked, you should use the **. If you want to store information across multiple pages, you should use the **?
- request; response
- response; request
- session; request
- request; session
Question 53: What would be a good name for this function?
- equals
- endsWith
- startsWith
- contains
Question 54: When it comes to the value of a variable, what is the difference between NULL and empty?
- NULL is a blank value; empty is the lack of a value.
- A NULL value has an allocated address in memory; empty does not.
- NULL refers to the lack of a value for an integer; empty refers to the lack of a value for a string.
- NULL is the lack of a value; empty is a blank value.
Question 55: Which is the most complete list of data types that PHP supports?
- string, integer, float, boolean, array, object, NULL, resource
- string, integer, boolean, array, object, NULL, resource
- string, integer, float, array, object, NULL, resource
- string, integer, float, boolean, array, object, NULL
Question 56: In PHP 7, What is the correct way to import multiple classes from namespace in a single declaration?!
- use myApp\myNamespace {ClassA, ClassB, ClassC};
- use myApp\myNamespace\ClassA, ClassB, ClassC;
- use myApp\myNamespace [ClassA, ClassB, ClassC];
- use myApp\myNamespace (ClassA, ClassB, ClassC);
Question 57: What is the resulting output of this for statement?
- kilometers = 0.6214 miles.
kilometers = 1.2428 miles.
kilometers = 1.8642 miles.
kilometers = 2.4856 miles.
kilometers = 3.107 miles.
- kilometers = 0.6214 miles.
kilometers = 1.2428 miles.
kilometers = 1.8642 miles
kilometers = 2.4856 miles.
kilometers = 3.107 miles.
kilometers = 3.7284 miles.
- kilometers = 1.2428 miles.
kilometers = 1.8642 miles.
kilometers = 2.4856 miles.
kilometers = 3.107 miles.
Question 58: Which PHP script finds the earliest and latest dates from an array?
- <?php
$dates = array (‘2018-02-01’, ‘2017-02-02’, ‘2015-02-03’);
echo “Latest Date: “. max($dates).” \n”;
echo “Earliest Date: “. min($dates).” \n”;
?>
- <?php
$dates = array (‘2018-02-01’, ‘2017-02-02’, ‘2015-02-03’);
echo “Latest Date: “. min($dates).” \n”;
echo “Earliest Date: “. max($dates).” \n”;
?>
- <?php
$dates = array (‘2018-02-01’, ‘2017-02-02’, ‘2015-02-03’);
echo “Latest Date: “. ($dates).” \n”;
echo “Earliest Date: “. ($dates).” \n”;
?>
- <?php
$dates = array (‘2018-02-01’, ‘2017-02-02’, ‘2015-02-03’);
echo “Latest Date:” max($dates).” \n”;
echo “Earliest Date:” min($dates).” \n”;
?>
Question 59: Which script might be used to continue a user’s search for music, across different webpages?
- <?php
start_session ();
$music = $_SESSION[‘music’];
?>
- <?php
session_start ();
$music = $SESSION[‘music’];
?>
- <?php
start_session ();
$music =$session[‘music’];
?>
- <?php
session_start ();
$music = $_SESSION[‘music’];
?>
Question 60: Imagine a web application, built following a MVC architecture, that contains a quiz and a button to score it, When the user presses the Score button, which component should handle the request?
- router
- controller
- model
- view
Question 61: A PHP “variable variable” takes the value of a variable and treats that as the name of a variable. For example, if $var is a variable then $$var is a variable variable whose name is the value of $var. Which script produces the output below, using variable variables?
- $name = “Cat”;
$name = “Dog”;
echo $name. “<br/>”;
echo $$name. “<br/>”;
echo $Dog;
- $name = “Cat”;
$$name = “Dog”;
echo $name. “<br/>”;
echo $$name. “<br/>”;
echo $Dog;
- $name = “Cat”;
$$name = “Dog”;
echo $name. “<br/>”;
echo $$name. “<br/>”;
echo $Cat;
- $name = “Cat”;
$$name = “Dog”;
echo $name. “<br/>”;
echo $name. “<br/>”;
echo $Cat;
Question 62: When should this php script be used?
- when a user goes to pay for an item online
- when items are placed in a cart
- at first registration
- at every login, for security
Question 63: What below script will print?
- 134
- 13
- 1
- 123
Question 64: Which is not a valid magic constant?
- __RESOURCE__
- __FUNCTION__
- __CLASS__
- __TRAIT__
Question 65: Why is it not recommended to make all of a class’s variables public?
- Doing so makes your code tightly coupled.
- The attribute may be accessed only by the class that defines the member.
- You will have no control over which values the attribute can take. Any external code will be able to change it without any constraint.
- You can then access the attribute only within the class itself, and by inheriting and parent classes.
Question 66: Which two functions can sanitize text and validate text formats?
- session_start () and filter_input ()
- filter_var () and filter_input ()
- preg_match () and strstr ()
Question 67: What is the correct way to include the file gravy.php in the middle of HTML code?
- <! – include file=” gravy.php”; –>
- <?php include gravy.php?>
- <?php include “gravy.php”?>
- <?php include file=” gravy.php”?>
Question 68: What are some of the main types of errors in PHP?
- notices, warnings, fatal
- runtime, logical, compile
- semantic, logical, syntax
- warnings, syntax, compile
Question 69: Your site must allow uploading of large files. What might you need to do?
- Make sure the user has the proper permissions.
- Keep a count of upload file sizes and log them.
- Change the upload_max_filesize configuration parameter.
- Be sure to use chunked transfer encoding.
Question 70: Which code will return the IP address of the client?
- $HTTP_SERVER_VARS(“REMOTE_IP”)
- $_SESSION[“REMOTE_ADDR”];
- $_SERVER[“HTTP_X_FORWARDED_FOR”]
- getenv(“REMOTE_ADDR”)
Question 71: DRY (Don’t Repeat Yourself) is a principle of software development aimed at reducing repetition of software patterns. Which choice is not a way to write DRYer code with PHP?
- inheritance
- classes
- namespacing
- dependency injection
Question 72: Describe what happens if you run this code in a testing environment:
- It displays: “Paris is the capital of France.”
- It displays:” is the capital of France.”
- It triggers a syntax error because the array keys on line 1 are in quotes.
- It triggers a syntax error because the array key on line 2 is in quotes.
Question 73: Which superglobal variable holds information about headers, paths, and script locations?
- $_SERVER
- $SERVER_VARIABLES
- $_ENV
- $GLOBALS
Question 74: What type of computer language is PHP?
- server-side scripting language
- compiled language
- machine language
- algorithmic language
Question 75: Which is not true of the toString () in PHP?
- It saves a lot of work of using setters’ methods to access the values of objects.
- It saves a lot of work of using getters methods to access the values of objects.
- It allows you to call an object and see its components as a string.
- It is automatically called when you use echo or print.
Question 76: Is the output of this code in descending order, shown vertically, and with spaces between numbers? And what is the output?
- This does not meet all the criteria because the resulting numbers will be “2461122”, which is in no particular order.
- This meets the criteria because the is present and sort () lists in descending order
- This does not meet all the criteria because the sort () function sorts an indexed array in ascending order. Thus, this code will display “2 4 6 11 22” shown vertically, but the numbers are spaced.
- does not meet all the criteria because the echo simply results in showing the array numbers in the order shown within the $numbers array, which is ascending
Question 77: Which function can you use in error handling to stop the execution of a script and is equivalent to exit ()?
- die
- return
- throw
- break
Question 78: Which are types of control structures in PHP?
- break, continue, do-while, exception, for, foreach, if, switch, throw, while
- values, operators, expressions, keywords, comments
- for, foreach, if, else, else if, switch, tries, throws, while
- if-then-else, do-while, for-each, go-to, stop-when
Question 79: Which loop displays all numbers from 1 to 10 inclusive?
- $i = 1; while ($i < 10) {echo $i++. ‘<br/>’;}
- $i = 0; while ($i <= 10) {echo $i++. ‘<br/>’;}
- while ($i < = 10) {echo ++$i. ‘<br/>’;}
- $i = 0; while ($i < 10) {echo ++$i. ‘<br/>’;}
Question 80: You want to find out what day Twelfth Night falls on after Christmas 2018. Which code should you use?
- $xmas = new DateTime (‘Dec 25, 2018’); $twelfth_night = $xmas->add (new DateInterval(‘P12D’)); echo $twelfth_night->format(‘l’);
- $twelfth_night = strtotime (‘December 25, 2018 + 12 days’); echo date (‘d’, $twelfth_night);
- $twelfth_night = strtotime (‘December 25, 2018 + 12 days’); echo strftime (‘%d’, $twelfth_night);
- $xmas = new DateTime (‘Dec 25, 2018′); $twelfth_night = $xmas->add (strtotime (’12 days’)); echo $twelfth_night->format(‘D’);
Question 81: Assume that $r is 255, and $g and $b are both 0. What is the correct code to output “#ff0000”?
- printf(‘#%2x%2x%2x’, 255, 0, 0);
- printf (‘#%2X%2X%2X’, $r, 0, 0);
- printf (‘#%x%x%x’, 255, 0, 0);
- printf (‘#%02x%02x%02x’, 255, 0, 0);
Question 82: Create an associative array using $array1 as the keys and $array2 as the values:
- $array3 = array_merge ($array1, $array2);
- $array3 = array_union ($array1, $array2);
- $array3 = array_keys ($array1, $array2);
- $array3 = array_combine ($array1, $array2);
Question 83: You want to use wildcard characters when searching for records in a MySQL/MariaDB database using a PDO prepared statement. Which code should you use?
- $statement->bindValue (‘:name’, ‘%’. $_GET[‘name’]. ‘%’);
- $statement->bindValue (‘%’. $_GET[‘name’]. ‘%’, ‘:name’);
- $statement->bindParam (‘:name’, ‘%’. $_GET[‘name’]. ‘%’);
- $statement->bindParam (‘%’. $_GET[‘name’]. ‘%’, ‘:name’);