Jump To Content
LearnHub
Home
Schools
Communities
Sign In
or
Sign Up
Search LearnHub
Keywords
laurellion’s Tests
About
Lessons
Tests
Courses
PHP Intermediate
A test by
Lawrence Badanai
.
Test Questions
Question
What colour cables should you use to connect a server running PHP to your network?
Answers
Correct
Answer Text
Colour doesn't matter.
White or Grey; coloured cables are to a lower spec than you need for a high performance engine such as PHP, and will give rise to a higher proportion of collisions.
You should avoid bright colours such as pink or yellow, since these cable tend to be crossed and are designed for use connecting two systems back to back for the syncronisation of data, rather than for the connection of a server to clients.
Question
The regular expression [a-z]{2,3}$ will only match
Answers
Correct
Answer Text
any string that ends with 2 or 3 lower case letters
any string that comprises 2 or 3 lower case letters
any string that starts with 2 or 3 lower case letters
any string that ends with 2 or more lower case letters
Question
By default, variables that you set in your PHP code are retained
Answers
Correct
Answer Text
Throughout the piece of PHP ( <?php to >> ) in which they are declared.
Throughout the current page, and subsequent pages run by the same user on your web site.
Throughout the piece of PHP ( <?php to >> ) in which they are declared, and in any functions which are called from that block
Throughout the PHP block ( { to } ) where they are declared, even if that PHP block has intermediate HTML sections within it.
Question
Which of these could be used to maintain a variable from one form to the next?
Answers
Correct
Answer Text
variable_issaved()
session_register()
An image watermark
static()
Question
Which of these statements is true?
Answers
Correct
Answer Text
PHP interfaces to a number of relational databases such as MySQL, Oracle and Sybase. A wrapper layer is provided so that code written for one database can easily be transferred to another if you later switch your database engine.
There's little code in PHP to help you interface to databases, but there's no reason why you can't write such code if you want to.
Question
If you want to change every occurrence of "Mary" to "Maria" in a variable, you would:
Answers
Correct
Answer Text
$string =~ s/Mary/Maria/;
Split the string at "Mary", the join it with "Maria".
Explode the string at "Mary", then Implode it with "Maria".
$string =~ s/\bMary\b/Maria/ig;
Question
The function used to delete a file is
Answers
Correct
Answer Text
unlink()
delete_file()
del()
delete()
rem()
remove()
Question
To read a file into an array, which function might you use?
Answers
Correct
Answer Text
There's no single function to do this; you have to use a loop, using fgets() to read each line and checking for completion using feof()
slurp()
file_read()
pull()
file()
array_walk()
Question
How would you add 1 to the variable $count?
Answers
Correct
Answer Text
count++;
$count =+1
$count++;
incr count;
incr $count;
Question
Which function(s) would you use to read a line of space separated fields, where double quotes and backslashes have been used to protect embedded spaces?
Answers
Correct
Answer Text
fgetcsv()
explode(fgets())
split(fgets())
fgetsplit()
Question
PHP can be used to generate server side graphics on a web site
Answers
Correct
Answer Text
False
True
Question
You can set a cookie (if the user is accepting them)
Answers
Correct
Answer Text
From within your PHP page, at any time
From within your PHP page; you can set a cookie at any time if your server is configured to buffer your output, but you can only send it before any regular (HTML) data is send to the browser if your server is configured to NOT buffer (see php.ini)
From within your PHP page, but only before it send out any data to the browser.
From instructions held in the php.ini file
From within your PHP page, but only after you've completed sending out the body of the response page.
Question
Are there regular expressions in PHP?
Answers
Correct
Answer Text
No - PHP uses "glob" style matching only
Yes - regular expressions use the POSIX standard
Yes - two sets. One uses tha POSIX standard and the other uses Perl-like conventions.
Yes - regular expressions use Perl-like conventions
Yes - regular expressions handling is the same as in awk and gawk
Question
If you want to break out of a while loop, what statement would you use?
Answers
Correct
Answer Text
close
elihw
exit
last
end
break
done
Answer
Test Statistics
Rating
Likes
4
Negative
0
Your Actions
Rate
Up
Down
Published In…
Everything PHP
Open Source
PHP and MySQL