Php Objective Questions for written test exams all

Question 1
What will the following script output?


$x = 3 - 5 % 3;

echo $x;

?>

A. 2

B. 1

C. Null

D. True

E. 3
View Answers
Question 2
Which data type will the $a variable have at the end of the following script?


$a = “1”;

echo $x;

?>

A. (int) 1

B. (string) “1”

C. (bool) True

D. (float) 1.0

E. (float) 1
View Answers
Question 3
What will the following script output?


$a = 1;

$a = $a— + 1;

echo $a;

?>

A. 2

B. 1

C. 3

D. 0

E. Null
View Answers
Question 4
What will the following script output?


class a

{

var $c;

function a ($pass)

{

$this->c = $pass;

}

function print_data()

{

echo $this->$c;

}

}

$a = new a(10);

$a->print_data();

?>

A. An error

B. 10

C. “10”

D. Nothing

E. A warning
View Answers
Question 5
When serializing and unserializing an object, which of the following precautions

should you keep in mind? (Choose two)

A. Always escape member properties that contain user input.

B. If the object contains resource variables, use magic functions to restore the

resources upon unserialization.

C. Use the magic functions to only save what is necessary.

D. Always use a transaction when saving the information to a database.

E. If the object contains resource variables, it cannot be serialized without first

destroying and releasing its resources.
View Answers
Question 6
What will the following script output?


error_reporting(E_ALL);

class a

{

var $c;

function a()

{

$this->c = 10;

}

}

class b extends a

{

function print_a()

{

echo $this->c;

}

}

$b = new b;

$b->print_a();

?>

A. Nothing

B. An error because b does not have a constructor

C. 10

D. NULL

E. False
View Answers
Question 7
Is it possible to pass data from PHP to JavaScript?

A. No, because PHP is server-side, and JavaScript is client-side.

B. No, because PHP is a loosely typed language.

C. Yes, because JavaScript executes before PHP.

D. Yes, because PHP can generate valid JavaScript
View Answers
Question 8
Is it possible to pass data from JavaScript to PHP?

A. Yes, but not without sending another HTTP request.

B. Yes, because PHP executes before JavaScript.

C. No, because JavaScript is server-side, and PHP is client-side.

D. No, because JavaScript executes before PHP.
View Answers
Question 9
Which types of form elements can be excluded from the HTTP request?

A. text, radio, and check box

B. text, submit, and hidden

C. submit and hidden

D. radio and check box
View Answers
Question 10
When processing the form, what is the difference between a hidden form element

and a nonhidden one, such as a text box?

A. The hidden form element does not have a name.

B. There is no difference.

C. The hidden form element does not have a value.

D. The hidden form element is excluded from the request.
View Answers
Question 11
Which of the following form element names can be used to create an array in

PHP?

A. foo

B. [foo]

C. foo[]

D. foo[bar]
View Answers
Question 12
When an expiration date is given in a Set-Cookie header, what is the resulting

behavior in subsequent requests?

A. If the expiration date has expired, the cookie is not included.

B. The behavior is the same; the expiration date is included in the Cookie

header, and you can access this information in the $_COOKIE superglobal

array.

C. The cookie persists in memory until the browser is closed.

D. The cookie is deleted and therefore not included in subsequent requests.
View Answers
Question 13
If you set a cookie with either setcookie() or header(), you can immediately

check to see whether the client accepted it.

A. True, you can check the $_COOKIE superglobal array to see if it contains the

value you set.

B. True, but only if register_globals is enabled.

C. False, you can only use setcookie() if you need to test for acceptance.

Using header() does not work.

D. False, you must wait until you receive another HTTP request to determine

whether it includes the Cookie header.
View Answers
Question 14
Why must you call session_start() prior to any output?

A. Because it is easy to forget if not placed at the top of your scripts.

B. Because you can no longer access the session data store after there has been

output.

C. Because session_start() sets some HTTP headers.

D. Because calling session_start() causes the HTTP headers to be sent.
View Answers
Question 15
Which of the following represents the proper way to set a session variable?

A. $_SESSION[‘foo’] = ‘bar’;

B. session_start();

C. session_set_save_handler (‘myopen’, ‘myclose’, ‘myread’,

‘mywrite’, ‘mydelete’, ‘mygarbage’);

D. $foo = $_SESSION[‘foo’];
View Answers
Question 16
Which of the following functions allows you to store session data in a database?

A. session_start();

B. session_set_save_handler();

C. mysql_query();

D. You cannot store session data in a database.
View Answers
Question 17
Which of the following types can be used as an array key? (Select three.)

A. Integer

B. Floating-point

C. Array

D. Object

E. Boolean
View Answers
Question 18
Which of the following functions can be used to sort an array by its keys in

descending order?

A. sort

B. rsort

C. ksort

D. krsort

E. reverse_sort
View Answers
Question 19
What will the following script output?


$a = array (‘a’ => 20, 1 => 36, 40);

array_rand ($a);

echo $a[0];

?>

A. A random value from $a

B. ‘a’

C. 20

D. 36

E. Nothing
View Answers
Question 20
Given

$email = ‘bob@example.com’;

which code block will output example.com?

A. print substr($email, -1 * strrpos($email, ‘@’));

B. print substr($email, strrpos($email, ‘@’));

C. print substr($email, strpos($email, ‘@’) + 1);

D. print strstr($email, ‘@’);

View Answers
Question 21
Which question will replace markup such as img=/smiley.png with
src=”/smiley.png”>?

A. print preg_replace(‘/img=(\w+)/’, ‘’, $text);

B. print preg_replace(‘/img=(\S+)/’, ‘’, $text);

C. print preg_replace(‘/img=(\s+)/’, ‘’, $text);

D. print preg_replace(‘/img=(\w)+/’, ‘’, $text);
View Answers
Question 22
Which of the following functions is most efficient for substituting fixed patterns in

strings?

A. preg_replace()

B. str_replace()

C. str_ireplace()

D. substr_replace()
View Answers
Question 23
If

$time = ‘Monday at 12:33 PM’;

or

$time = ‘Friday the 12th at 2:07 AM’;

which code fragment outputs the hour (12 or 2, respectively)?

A. preg_match(‘/\S(\d+):/’, $time, $matches);

print $matches[1];

B. preg_match(‘/(\w+)\Sat\S(\d+):\d+/’, $time, $matches);

print $matches[2];

C. preg_match(‘/\s([a-zA-Z]+)\s(\w+)\s(\d+):\d+/’, $time,

$matches);

print $matches[3];

D. preg_match(‘/\s(\d+)/’, $time, $matches);

print $matches[1];

E. preg_match(‘/\w+\s(\d+):\d+/’, $time, $matches);

print $matches[1];
View Answers
Question 24
Which of the following output ‘True’?

A. if(“true”) { print “True”; }

B. $string = “true”;

if($string == 0) { print “True”; }

C. $string = “true”;

if(strncasecmp($string, “Trudeau”, 4)) { print “True”; }

D. if(strpos(“truelove”, “true”)) { print “True”; }

E. if(strstr(“truelove”, “true”)) { print “True”; }
View Answers
Question 25
What are the contents of output.txt after the following code snippet is run?


$str = ‘abcdefghijklmnop’;

$fp = fopen(“output.txt”, ‘w’);

for($i=0; $i< 4; $i++) {

fwrite($fp, $str, $i);

}

?>

A. abcd

B. aababcabcd

C. aababc

D. aaaa
View Answers
Question 26
Which of the following can be used to determine if a file is readable?

A. stat()

B. is_readable()

C. filetype()

D. fileowner()

E. finfo()
View Answers
Question 27
Specifying the LOCK_NB flag to flock() instructs PHP to

A. Return immediately if someone else is holding the lock.

B. Block indefinitely until the lock is available.

C. Block for a number of seconds dictated by the php.ini setting

flock.max_wait or until the lock is available.

D. Immediately take control of the lock from its current holder.
View Answers
Question 28
If you have an open file resource, you can read data from it one line at a time with

the _____ function.
View Answers
Question 29
Which of the following functions require an open file resource?

A. fgets()

B. fopen()

C. filemtime()

D. rewind()

E. reset()
View Answers
Question 30
Which of the following sentences are incorrect?

A. date() returns the current UNIX datestamp.

B. date() returns a formatted date string.

C. date() requires a time stamp to be passed to it.

D. date() returns a date array.

View Answers
Question 31
The ________ function will return the current UNIX time stamp.

View Answers
Question 32
Which of the following functions will output the current time as 11:26 pm?

A. print date(‘H:m a’);

B. print date(‘G:M a’);

C. print date(‘G:i a’);

D. print strftime(‘%I:%M %p’);
View Answers
Question 33
The PHP date functions are only guaranteed to work for dates after _____.

A. January 1, 1970 00:00:00

B. January 1, 1900 00:00:00

C. January 1, 1963 00:00:00

D. January 18, 2038 22:14:07
View Answers
Question 34
Internally PHP handles dates and times as

A. A ‘date array’ array consisting of the year, month, day, hour, minute, and

second.

B. A UNIX time stamp representing the number of seconds since the UNIX

epoch.

C. An ISO-8601 date entity.

D. A UNIX time stamp consisting of the number of microseconds since the

UNIX epoch.
View Answers
Question 35
Your company sells a shopping cart written in PHP. Matching common industry

practice, the shopping cart sends a confirmational email to the user after he has

checked out.

Your team has just ported the shopping cart from PHP on Gentoo Linux to PHP

running on Windows Server 2003.They’ve correctly set the SMTP, smtp_port, and

sendmail_from settings in php.ini, but this error appears when the shopping cart

tries to send the confirmation email:

Could not execute mail delivery program ‘sendmail’

This is your team’s first project using Windows Server, and everyone’s a bit confused

as to why this error is happening.The php.ini settings work fine on Linux,

so what could be the problem?

Choose from one of the following:

A. The smtpserver service hasn’t been started.

B. sendmail_path in php.ini needs to be commented out.

C. Microsoft Exchange needs configuring to accept email from PHP.

D. PHP cannot send email when running on Windows.
View Answers
Question 36
Flush with the success of the shopping cart on Windows Server 2003, your company

has decided that it would be a good idea to add Solaris to the list of supported

operating systems. Because the shopping cart is already proven to work on

Linux, it should be no trouble at all to get the cart working on Solaris.

Your team goes out and buys a new Sun server. As Solaris doesn’t come with PHP,

you have to compile PHP by hand. At the same time, your network administrator

decides to un-install the Solaris version of sendmail and replace it with the company’s

standard MTA—postfix—instead. He forgets to tell you that he’s done this.

When the time comes to test your shopping cart on Solaris, there’s a problem.

When the shopping cart tries to send the confirmation email, you get this error

message:

Call to undefined function: mail()

What can you do to fix this problem?

A. Put an @ symbol in front of your call to mail() so that PHP does not output

the error message.

B. Put sendmail back on the machine. Postfix doesn’t provide a sendmail wrapper

anyway.

C. Use mb_send_mail() instead.

D. Recompile PHP—after asking your network administrator to leave the

MTA alone until the recompilation of PHP has completed
View Answers
Question 37
All the new customers you’re attracting on Solaris are very pleased with your

shopping cart.Your product is earning them a lot of new customers also.

However, like all customers, they want new features. Specifically, they want you to

create and attach a simple comma-separated file that users can import into products

such as Microsoft Money.This will make it easier for customers to manage

their finances. Besides, it’s a cool feature that none of your competitors have, so the

marketing department has told your boss to get it done.

At the moment, the shopping cart sends out RFC-822–compliant plain-text

emails.What do you need to change to make it send the attachment as well?

Choose from one of the following:

A. Replace your plain-text emails with MIME-encoded emails.

B. Refuse to do it. RFC-822 doesn’t allow attachments, and your company

should not be shipping products that go against Internet standards.

C. Put the CSV file on a web server, and put a link to it in the email.

D. Ditch PHP’s built-in mail() function, and use the system() command to

call sendmail directly.
View Answers
Question 38
A rival has just launched a new version of his shopping cart. Unlike yours—which

only sends plain-text emails—his shopping cart sends out confirmation emails that

look more like a web page.These emails look so much nicer, and he’s starting to

eat into your sales as a result. It’s a good thing his cart only runs on Windows; otherwise,

you’d have no customers left!

Something must be done, and marketing has decided that if you can’t beat them,

join them.Your long-suffering boss has been told to make your shopping cart send

out nice-looking emails too. In the best tradition of pointy-haired bosses, he’s

dumped the whole problem in your lap, and is waiting for you to tell him how

this can be done.

What could you do to make this work? Choose one or more of the following:

A. Change your emails to send text/html MIME-encoded emails.

B. It’s time to ditch mail() again and call sendmail directly.

C. Change your emails to send text/enriched MIME-encoded emails.

D. Tell your boss that this only works

on Windows because PHP on Windows

handles emails very differently.

View Answers
Question 39
During testing of your new, much nicer-looking confirmation emails, you notice

that there’s a problem.The email uses quite a few images—including the allimportant

company logo. All of these images are stored on your web server, and

the email uses standard “” tags to include them.The images look

great in your email client—but appear as missing images when you send the email

to your boss to show him the results of your hard work.

Your boss isn’t pleased, and neither is the marketing department, who make it very

clear that you can’t ship the code until the company logo shows up.

The good news is that it isn’t just your email.The confirmation emails sent by

your rival also have this problem. If you can figure out how to make it work, not

only will you be playing catch-up to your rival, but you’ll also be back in the lead.

This mollifies your boss, but gets you nowhere nearer to solving the problem.

What could you change to make this work? Choose one or more of the

following:

A. sendmail is too old. Replace it with a modern MTA instead.

B. Add all the images to the email as attachments with Content-Locations,

and make your email use the attachments rather than the images on the

website.

C. Add a piece of inline JavaScript in your email that temporarily changes the

security settings of the email client.This will enable the images to be downloaded.

D. File a bugwith the author of the email client that your boss uses. Something

must be wrong with the way it handles RFC-1896–compliant email messages.

View Answers
Question 40
Which of the following is not an aggregate function?

A. AVG

B. SUM

C. COUNT

D. GROUP BY

E. MIN
View Answers
Question 41
In the following query, how will the resultset be sorted?

Select * from my_table order by column_a desc, column_b, column_c

A. By column_a in descending order, by column_b in descending order, and,

finally, by column_c.

B. By column_a, column_b, and column_c, all in descending order.

C. By column_a, column_b, and column_c, all in ascending order.

D. By column_a.Any rows in which column_b has the same value will then be

resorted by column_c in descending order.

E. By column_a in descending order.Any rows in which column_a has the

same value will then be ordered by column_b in ascending order.Any rows

in which both column_a and column_b have the same value will be further

sorted by column_c in ascending order.
View Answers
Question 42
How is a transaction terminated so that the changes made during its course are

discarded?

A. ROLLBACK TRANSACTION

B. COMMIT TRANSACTION

C. By terminating the connection without completing the transaction

D. UNDO TRANSACTION

E. DISCARD CHANGES
View Answers
Question 43
The company you work for writes and sells a successful content management system

(CMS). The CMS is written in PHP.

Recently, your company has acquired the assets of one of your main competitors,

including their CMS. The plan is to discontinue the rival CMS, and migrate all of

its current customer base over to your CMS. However, this isn’t going to happen

until you’ve added some of the features that your CMS is currently lacking.

The first feature that you have to add is a dead link checker. This handy little utility

runs from the command-line, and checks a list of URLs to see whether they

still work or not. Thanks to the new streams support in PHP 4.3, this should be

very easy to do.

Unfortunately, the first time you test your code, this error appears on the screen:

Warning: fopen(): URL file-access is disabled in the server configuration in

on line 3

Warning: fopen(URL): failed to open stream: no suitable wrapper could be

found in on line 3

What is the cause of this error? Choose from one of the following.

A. File wrappers don’t allow you to access websites. You need to use the

CURL extension for that.

B. The web server is running behind a firewall, which is preventing access out

to the Internet.C. The web server’s configuration file contains the setting

‘allow_fopen_url=Off ’, which prevents the PHP file wrappers from

working.

D. The php.ini configuration file contains the setting ‘allow_fopen_url=Off ’,

which prevents the PHP file wrappers from working.
View Answers
Question 44
Now that you’ve fixed that little problem and are able to connect to remote websites

from your PHP script, you’re faced with another problem.

Your script’s job is to determine whether or not a given URL is valid. How is

your script going to do that?

Choose from one or more of the following options.

A. If the fopen() call fails, your script can assume that the remote website no

longer exists.

B. Once you have opened the file wrapper, try reading from the file. If the

read fails, then the remote web page no longer exists.

C. Check the metadata returned by opening the file, and use the HTTP status

code returned by the server to determine whether or not the remote

webpage still exists or not.

D. You can’t use PHP to reliably check whether remote URLs exist or not.

That’s why all these tools are always written in Java.
View Answers
Question 45
Decoding the status code contained in the file wrapper’s metadata is an important

task.

Where should you look to understand what the status code means?

Choose from one or more of the following:

A. The PHP Manual. It’s well annotated, so even if the PHP developers forgot

to list the status codes, you can be sure that a helpful PHP user has added

them somewhere.

B. Microsoft.com. Internet Information Server is the web server of choice for

many companies. Open standards are a nice ideal, but in the real world if

code doesn’t work for customers, you don’t get paid.

C. W3C.org. They set the standards, and standards are important. By supporting

the open standards, you can be sure that your code will work with most

of the products out in the marketplace.

D Apache.org. The Apache web server is more popular than all the other web

servers put together. If your code works with Apache, then it supports the

market leader. And that’s an important position to be in.
View Answers
Question 46
Your boss was so impressed with your new dead link checker tool that he’s given

you responsibility for adding a larger feature to the CMS product proper.

He wants you to add file replication support.

For large websites, it can be very expensive to purchase a server powerful enough

to cope with all the traffic and associated load. It’s often much cheaper to purchase

three or four smaller web servers, with a more powerful server acting as the

admin server. New content is added to the admin server, and then pushed out to

the smaller web servers.

Although most of the content lives in a shared database, original media files (PDF

files, images,Word documents, and the like) are served directly off disk. This is

partly a performance decision, and partly because some database servers have

severe limits on their support for replicating large amounts of binary data.

You must write some code to copy files from the admin server to one or more

web servers. There are no firewalls between the servers.

How would you do this? Choose one or more of the following options.

A. Put the media files into the database, and configure the web servers to

retrieve the files from the database when they are needed.

B. Use file wrappers to write the media files out to a \\server\share network

share.

C. Don’t use file wrappers at all. Use NFS to mount the disks from the admin

server on all the web servers, and access the files directly.

D. Use NFS to mount the disks from the web servers directly onto the admin

server. Have the admin server write to each of the NFS mounts in turn.
View Answers
Question 47
Customers are fickle things.

Just as you have your new file replication code working, one of your major customers

informs you that they have installed a firewall between the admin server

and the web servers.

This totally prevents your file replication code from working.

Helpfully, the customer does allow outgoing HTTP connections through the firewall.

You’ll need to provide an alternative script, that uploads the files to the web

servers through a HTTP connection. How are you going to do that?

Choose from one or more of the following.

A. File wrappers can’t upload files via http. You’ll have to use the CURL

extension to achieve this.

B. Just open a URL as a file and write to it. The whole point of file wrappers

is to make operations like this easy.

C. Use the stream context to tell the http file wrapper where to upload the file,

and have a script on the web servers move the file from the uploads directory

to their final destination.

D. Use the FTP file wrapper to upload files directly to their final destination.
View Answers
Question 48
With file replication done and dusted, your boss is confident that he’ll soon have

customers migrating across from the discontinued CMS to your product. He’ll

have no trouble making his targets for the quarter, and earning his bonus.

However, he needs one more feature porting across before he can be certain that

View Answers
Question 49
Which of the following data filtering methods can be described as a whitelist

approach?

A. Make sure that a username does not contain backticks or angled brackets.

B. Only allow alphanumerics and underscores in a username.

C. Pass all incoming data through strip_tags().

D. Use htmlentities() to escape potentially malicious characters.
View Answers
Question 50
With register_globals enabled, which of the following practices is particularly

important?

A. Initialize all variables.

B. Filter all foreign data.

C. Escape all data used in SQL statements.

D. Escape all data prior to output.
View Answers
Question 51
What are the two most important practices to mitigate the risk of an SQL injection

vulnerability?

A. Disabling register_globals and enabling safe_mode.

B. Enabling safe_mode and filtering any data used in the construction of the

SQL statement.

C. Filtering and escaping any data used in the construction of the SQL statement.

D. Disabling register_globals and escaping any data used in the construction

of the SQL statement.
View Answers
Question 52
If $foo is anticipated to be a string, what modification made to the following

query will mitigate the risk of an SQL injection vulnerability?

$sql = “insert into mytable values ($foo)”;

A. Specify the column name in the SQL statement.

B. Remove the parentheses surrounding $foo.

C. Replace the parentheses surrounding $foo with single quotes.

D. Add single quotes around $foo
View Answers
Question 53
What is the purpose of the escapeshellcmd() function?

A. To prepare data so that it can be used as a single argument in a shell command.

B. To remove malicious characters.

C. To escape metacharacters, so that they can’t be used to execute arbitrary

commands.

D. To prevent cross-site scripting attacks
View Answers
Question 54
What is the purpose of the escapeshellarg() function?

A. To prepare data so that it can be used as a single argument in a shell command.

B. To remove malicious characters.

C. To escape metacharacters, so that they can’t be used to execute arbitrary

commands.

D To remove arguments from a shell command
View Answers
Question 55
When is cross-site scripting a heightened risk?

A. When storing data submitted by the user.

B. When displaying foreign data.

C. When executing a shell command.

D. When opening a remote URL.
View Answers
Question 56
Which of the following functions can be used to escape data such that it can be

displayed without altering the appearance of the original data?

A. htmlspecialchars()

B. addslashes()

C. escapeshellargs()

D. urlencode()
View Answers
Question 57
What is the purpose of the open_basedir directive?

A. To indicate the directory that include() calls will use as a base.

B. To restrict file open access to a specific directory.

C. To set the working directory.

D. To allow additional file open access than that granted by safe_mode.
View Answers
Question 58
Which of the following activities can safe_mode help prevent?

A. Browsing the filesystem with a specially crafted PHP script.

B. Writing a Bash shell script to read session data.

C. Browsing the filesystem with a specially crafted Perl script.

D. Accessing another user’s database.
View Answers
Question 59
How can the following line of code be improved?

$db->query(“insert into foo values($id,$bar)”);

A. Use addslashes and sprintf to avoid security holes and make the code

cleaner

B. Split the query over several lines

C. Use mysql_query() instead of $db->query()

D. Define the table fields that will be affected by the INSERT statement

E. Use mysql_query()instead of $db->query() and addslashes to avoid

security holes
View Answers
Question 60
You developed a big application accessed by several thousand users at the same

time. Suddenly, your web server stops responding and users are getting connection

errors.What could have happened?

A. The database server was terminated because of the unusually high amount of

database accesses.

B. The web server was misconfigured so that it ran into virtual memory usage

and consequent resource starvation because of too many child processes.

C. You didn’t optimize your code design properly.
View Answers
Question 61
You are in a team of developers working on a number of different business applications.

Your project manager tells you that in two weeks another three PHP

developers will join the team and that you have to ensure that they will be ready

to dive in to the current PHP code without problems.What could you do?

A. Write proper end user documentation on how to use the web front end.

B. Write proper end user documentation and generate proper PHPDoc comments

inside the code to get an API documentation.

C. The absence of documentation will actually encourage the new developers

to delve more deeply into the code.
View Answers
Question 62
Suppose that you are receiving input from the user in the form of the string

“0mydeviceid” for a field for which you only allow valid numeric values.You

want to test if this variable is equal to 0 and, if it isn’t, output an error.Which

comparison operation should you use?

A. (0 = “0mydeviceid”)

B. (0 == “0mydeviceid”)

C. (0 === “0mydeviceid”)

D. None of the above
View Answers
Question 63
Which of the following strings are not valid modes for the fopen() function?

A. a+b

B. b+a

C. at

D. w

E. x+
View Answers
Question 64
Consider the following piece of code:


$arr = array(3 => “First”, 2=>“Second“, 1=>“Third“);

list (, $result) = $arr;

?>

After running it, the value of $result would be

A. First

B. Second

C. Third

D. This piece of code will not run, but fail with a parse error.
View Answers
Question 65
In standard SQL-92, which of these situations do not require or cannot be handled

through the use of an aggregate SQL function? (Choose 2)

A. Calculating the sum of all the values in a column.

B. Determining the minimum value in a result set.

C. Grouping the results of a query by one or more fields.

D. Calculating the sum of all values in a column and retrieving all the values of

another column that is not part of an aggregate function or GROUP BY clause.

E. Determining the mean average of a column in a group of rows.
View Answers
Question 66
Multidimensional arrays can be sorted using the ______ function.
View Answers
Question 67
When using the default session handler files for using sessions, PHP stores

session information on the harddrive of the webserver.When are those session

files cleaned up?

A. PHP will delete the associated session file when session_destroy() is

called from within a script.

B. When the function session_cleanup() is called, PHP will iterate over all

session files, and delete them if they exceeded the session timeout limit.

C. When the function session_start() is called, PHP will iterate over all

session files, and delete them if they exceeded the session timeout limit.

D. When the function session_start() is called, PHP will sometimes iterate

over all session files, and delete them if they exceeded the session timeout

limit.

E. Session files are never removed from the filesystem, you need to use an automated

script (such as a cronjob) to do this.
View Answers
Question 68
What is the order of parameters in the mail() function?

A. subject, to address, extra headers, body

B. to address, subject, extra headers, body

C. to address, subject, body, extra headers

D. subject, to address, body, extra headers
View Answers
Question 69
Which of the following statements are correct? (Choose 3)

A. sprintf() does not output the generated string.

B. printf(“%2s%1s“, “ab“, “c“) outputs the string abc.

C. vprintf() takes at least one parameter; the first parameter is the formatting

string and the following parameters are the arguments for the ‘%’

placeholders.

D. printf(“%c“, “64“) will output @ and not 6.

E. sprintf(“%3.4f“, $x) outputs more than 7 characters.

F. number_format() inserts thousands of separators and decimal points different

from (,) and (.) respectively, while printf() like functions always use

(.) as decimal point.
View Answers
Question 70
The requirement is to return true for the case in which a string $str contains

another string $substr after the first character of $str? Which of the following

will return true when string $str contains string $substr, but only after the first

character of $str?

I.


function test($str, $substr) {

return strpos(substr($str,1), $substr) >= 0;

\}

?>

II.


function test($str, $substr) {

return strrchr($str, $substr) !== false;

\}

?>

III.


function test($str, $substr) {

return strpos($str, $substr) > 0;

\}

?>

A. I only

B. II only

C. III only

D. I and II

E. I and III

F. II and III
View Answers
Question 71
Which of the features listed below do not exist in PHP4? (Choose 2)

A. Exceptions

B. Preprocessor instructions

C. Control structures

D. Classes and objects

E. Constants
View Answers
Question 72
What is the output of the following code snippet?


class Vehicle {

\}

class Car extends Vehicle {

\}

class Ferrari extends Car {

\}

var_dump(get_parent_class(“Ferrari”));

?>

A. string(7) “Vehicle“

B. string(3) “Car“

C. array(2) {

[0]=>

string(7) “vehicle“

[1]=>

string(3) “car“

\}
View Answers
Question 73
The following PHP script is designed to subtract two indexed arrays of numbers.

Which statement is correct?


$a = array(5, 2, 2, 3);

$b = array(5, 8, 1, 5);

var_dump(subArrays($a, $b));

function

subArrays($arr1,

$arr2)

{

$c = count($arr1);

if

($c != count($arr2))

return

null;

for($i = 0;

$i < $c;

$i++)

$res[$i]

$arr1[$i] - $arr2[$i];

return $res;

\}

?>

A. The script is valid.

B. Assignments must be made on a single line.

C. It has too many linefeed characters between statements.

D. No, the script is missing curly braces.

E. Yes it is valid, but the script will not work as expected.
View Answers
Question 74
What is the purpose of the escapeshellarg() function?

A. Removing malicious characters.

B. Escaping malicious characters.

C. Creating an array of arguments for a shell command.

D. Preparing data to be used as a single argument in a shell command.

E. None of the above.
View Answers
Question 75
The _________ function can be used to determine if the contents of a string can

be interpreted as a number.
View Answers
Question 76
Assume $comment contains a string.Which PHP statement prints out the first 20

characters of $comment followed by three dots (.)?

A. print substr($comment, 20) . ‘...‘;

B. print substr_replace($comment, ‘...‘, 20);

C. print substr($comment, 20, strlen($comment)) . ‘...‘;

D. print substr_replace($comment, 20, ‘...‘);
View Answers
Question 77
What is the name of the function that you should use to put uploaded files into a

permanent location on your server?
View Answers
Question 78
If you have a file handle for an opened file, use the __________ function to send

all data remaining to be read from that file handle to the output buffer.
View Answers
Question 79
Which of the following sentences are not true? (Choose 2)

A. strpos() allows searching for a substring in another string.

B. strrpos() allows searching for a substring in another string.

C. strpos() and strrchr() return -1 if the second parameter is not a substring

of the first parameter.

D. strpos() and strrpos() can return a value that is different from an integer.

E. The second parameter to substr() is the length of the substring to extract.

F. strstr() returns false if the substring specified by its second parameter is

not found in the first parameter.
View Answers
Question 80
Which of the following sentences are correct? (Choose 2)

A. time() + 60*60*100 returns the current date and time plus one hour.

B. time() + 24*60*60 returns the current date and time plus one day.

C. time() + 24*60*60*100 returns the current date and time plus one day
View Answers

  








--------- Tutorials ---