Freelancer PHP Level 1 Exam Questions Answers is an open platform for the skilled person to get projects and jobs according to their expertise. There are many types of projects there like Fixed Price Projects, Hourly and Contests. One can get their job done by an Expert on either side of the globe.

There are options to bid on the project and submit your proposals. The person who is looking for an expert will evaluate your profile , proposal and skill and then after conversation you get rewarded for this project. After successfully completing the stages you will get mile stones created by the Employer.

But at the same time the competition is High and It’s tough to get recognised by the employer. Freelancer provides assessment of the skills of various levels.

You can try these exams or quizzes and after completing it by scoring the appropriate marks set by the Freelancer you will get a badge of the Level of the Skill.

And this badge will make an impact on employers that you have knowledge of a particular skill.


Passing an exam increases your chances to get awarded the project by your employer. In This Section You will get stuff that is really helpful to you in clearing the Freelancer PHP Level 1 Exam. We have listed almost the questions asked in Exam and Answers for the same.

The file handle argument in fread() allows you to specify ___________.

Answer: the number of bytes you wish to read


$count = $count + 8; can be written as:

Answer: $count += 8;


Which of the following is a special PHP variable that is used under HTTP Authentication?



XML is used for:

Answer: All of these

Data manipulation and storage

Display formatted data in a browser using style sheets.

transfer data between organizations

transfer data between software applications


Which kind of reference action allows you to have two variables referring to the same content?

Answer: Assign by reference.


____________ describes the structure of a class of XML documents, specifying how elements are related and allowed.

Answer: Document Type Definition


Which parameter of setcookie() indicates that the cookie should only be transmitted over a secure HTTPS connection from the client?

Answer: secure


Which of the following can be included in a phar file?

Answer: All of these

a manifest describing the contents

a signature for verifying integrity

a stub

the file contents


Which of the following will encrypt a password?

Answer: crypt($password);


Which of the following will connect to a data base using PEAR?

Answer: DB::connect(data_source_name);


Which of the following will return 1 if the Memcache session handler is available and 0 if not?



Which bz library function returns bzip2 encoded data after compressing a given string?

Answer: bzcompress()


Which function opens a memcached server persistent connection?

Answer: Memcache::pconnect


On the additional header that PHP allows you to include on an email you can add:

Answer: All of these




MIME version

X-mailer and version number


__________ is the same as setcookie() but the cookie value will not be automatically urlencoded when sent to the browser.

Answer: setrawcookie()


Which function enables automatic compression of large values?

Answer: Memcache::setCompressThreshold


Which of the following will send queries to a database using PEAR?

Answer: none of these







Which PHP library allows you to connect to and communicate with different types of servers using many different types of protocol?

Answer: cURL


Which configuration directive sets the size of data chunks for transfers?

Answer: memcache.chunk_size


What does PEAR stand for?

Answer: PHP Extension and Application Repository


Which of the following functions are used to encrypt passwords?

Answer: md5() and crypt()


Which cURL function sets an option on the given cURL session handle?

Answer: curl_setopt


Which of the following are examples of resource types in cURL?

Answer: cURL handle and a cURL multi handle


Which API treats XML as flow-through string data?

Answer: CAX


What does XML mean?

Answer: eXtensible Markup Language


singleton design pattern

Answer: Sometimes it’s important to have only one instance for a class. For example, in a system there should be only one window manager (or only a file system or only a print spooler). Usually singletons are used for centralized management of internal or external resources and they provide a global point of access to themselves.


PHP magic constant

Answer: __LINE__


When a small window pops up in front of the browser asking your username and a password, what kind of Authentication is being used?

Answer: HTTP


In session management cookies are usually not used for:

Answer: logging the user in for the first time


Which function returns the version of the server?

Answer: Memcache::getVersion


Which character must be set in the $mode argument for fopen($file, $mode) to open a file for reading and writing?

Answer: r+;


Which of the following will open the file “time.txt” as readable?

Answer: fopen(“time.txt”,”r”);


_____________ attempts to establish an FTP connection to a remote server by emulating an FTP client.

Answer: FTP ftp_connect()


Which of the following is the correct syntax to retrieve an object from the memcache module?

Answer: $result = $memcache->get(‘key’);


Which of these will perform integer rather than floating point division?

Answer: intval(x/y)


$count = $count * 3; can be written as:

Answer: $count *= 3;


What is the correct way to add 1 to the $counter variable?

Answer: $counter++;


Which operator appends the argument on the right side to the argument on the left side?

Answer: .=


With the ________ bitwise operator, the bits set in $a are not set, and the not set bits are then set.

Answer: ~


Which bitwise operator will set the bits that are set in either $a or $b.

Answer: ” | “


Which of the following allows you to set a user-defined exception handler function?

Answer: set_exception_handler


In an object method, which of the following is always a reference to the caller object?

Answer: $this


Which kind of reference is used by creating a local variable in a function and a variable in the calling scope referencing the same content?

Answer: Assign by reference.


Which of the following returns the remainder of $a divided by $b?

Answer: $a % $b


What PHP operator is used to access methods and properties of objects?

Answer: ” -> “


Which interface type allows you to chain methods of an object together?

Answer: Fluent Interfaces


Interfaces define a “contract” specifying that an object is capable of implementing a method ____________.

Answer: Specifying exactly how is to be done.


What is the correct way to create a function in PHP?

Answer: function yourFunction()


Which of the following will print “Hi ” followed a name argument passed to the function?

Answer: function sayHi ($name){ print “Hi $name”; }


Include files must have the file extension:

Answer: none of these


What is the term for using a class to create an object?

Answer: Instantiation


PHP constants:

Answer: All of these apply


Can be accessed anywhere in the script regardless of the scope.

Can be used as default argument values.

Cannot change during the execution of the script.

Follow the same rules as labels in PHP.


Which statement can replace several else Statements?

Answer: switch


To retrieve information from a form that is submitted using the “get” method, use ___________.

Answer: $_GET[];


Which POSIX function takes the following two string arguments and an optional third-array argument: A POSIX-style regular expression pattern, and the target string to be matched?

Answer: ereg()


Which PHP operator will attempt to execute its contents as a shell command?

Answer: (` `)


What function takes any number of numerical arguments and returns the largest of the arguments?

Answer: max()


To unregister a session variable STRING use:

Answer: session_unregister(STRING);


Which of the following is correct to select a database in MS SQL?

Answer: mssql_select_db(STRING)


Select the variable used to set the php.ini file to send emails containing the address of the default PHP mail sender.

Answer: sendmail_from


Which configuration directive is used to transparently failover to other servers on errors?

Answer: memcache.allow_failover


Which PHP function is identical to the C fwrite() function?

Answer: fputs()


Which function writes a string to a file?

Answer: file_put_contents


To denote strings in PHP, you can use both double quotes ” ” and which other characters?

Answer: single quotes ‘ ‘


What kind of elements can be contained in constants?

Answer: All of these







Which PHP operator type allows you to execute its contents as a shell command?

Answer: Execution operator


PHP variables start with the following symbol:

Answer: $


Which POSIX function takes a pattern, a target string, and an optional limit on the number of portions to split the string into.

Answer: split


What function raises the first argument to the power of the second argument, with decimal places to be specified by the scale factor?

Answer: bcpow


Instead of a single new line character some clients require which characters?

Answer: “\r\n”


Which function parses input from a file according to a format?

Answer: fscanf


Which file should be edited to set configuration directives?

Answer: php.ini


Which of the following is correct in PHP?

Answer: Zero is interpreted as false


Which parameter of setcookie() defines the amount of time for which a cookie is valid?

Answer: expire


Which control structure allows you to quickly traverse through an array?

Answer: foreach loops


Which types of code can be affected by namespaces?

Answer: Classes, functions and constants.


Although any valid PHP code can be contained within a namespace, only four types of code are affected by namespaces: classes, interfaces, functions and constants.


Which cURL function returns the last error number?

Answer: curl_errno


Which of the following is an invalid constant name?

Answer: 2DAY


Which PHP operator allows you to assign values to variables and arrays?

Answer: “=”


What is the term for breaking the binding between a variable name and variable content?

Answer: Unsetting references.


Which is the operator for the integer remainder from the division of two values?

Answer: %


Which predefined Memcache function turns on data compression?



Which compressed file type can be decompressed without specifying the extension?

Answer: zip


Which configuration directive, in conjunction with memcache.allow_failover, defines how many servers to try when setting and getting data?

Answer: memcache.max_failover_attempts


The correct way to create a numeric variable “v” that might have any real number is:

Answer: $v;


Which of the following databases are supported by PHP?

Answer: All of these



Oracle and Informix

PostgreSQL and Frontbase

mSQL and Interbase


Which of the following is the line to enable in the php.ini file for Windows in order to be able to use DBX?

Answer: extension=php_dbx.dll


Which of the following is the correct way to connect to a mySQL Server?

Answer: mysql_connect(SERVER, USER, PASSWORD);


Which of the following will return variables from a form sent by the HTTP POST method in PHP?

Answer: $_POST


Which version of PHP introduced object oriented programming?

Answer: PHP III


Which of the following will correctly create a constant “const”?

Answer: const const;


What variable is used by session cookies as a user ID?



Functions that represent a behavior of a class are called _________.

Answer: Methods


Which zip function retrieves the compressed size of a directory entry?

Answer: zip_entry_compressedsize


What does cURL stand for?

Answer: Client URL


Which function clears the cache of file status info?

Answer: clearstatcache


Which method defines HTTP Authentication using Apache Server?

Answer: .htaccess files


What is the most widely accepted meaning of the acronym “PHP” today?

Answer: PHP: Hypertext Preprocessor


_______________ defines a cookie to be sent along with the rest of the HTTP headers.

Answer: setcookie()


A special method to perform any activity required to instantiate an object is called a(n) __________.

Answer: Constructor


Which POSIX character matches zero or more instances of the previous regular expression?

Answer: *


Which POSIX character matches any character?

Answer: .


If an exception is not caught, a PHP Fatal Error will be issued with what message?

Answer: “Uncaught Exception …”


Which statement retrieves the value of a function after it is called?

Answer: return


Which “magic” constant implemented inside an include, returns the directory of the included file.

Answer: _DIR_


Which function returns a string containing a byte-stream representation of any value that can be stored in PHP?

Answer: serialize()


How do you write “Hello World 2010” in PHP?

Answer: echo “Hello World 2010”;


Which command returns the filename component of a path?

Answer: string basename ( string $path [, string $suffix ] )


Which file mode will read and write to the end of an existing file or create a new file?

Answer: “a+”


Which server verifies the name password and mail spool location?

Answer: SMTP Server


What does MTA stand for?

Answer: Mail Transfer Agent


The agent used to collect and access the mail spool is called:

Answer: Mail Transfer Agent – not sure


__________ is an extension that provides a way to put entire PHP applications into a single file called PHP Archive for easy distribution and installation.

Answer: phar


Which function is used to connect to a database using Authentication by SQL Database Query?

Answer: @mysql_connect(“localhost”,”databaseuser”,”password”)


Which function takes a single argument and returns the largest integer that is less or equal to that argument?

Answer: floor()


Which function takes a single argument and returns the smallest integer that is greater than or equal to that argument?

Answer: ceil()


What is the expression for returning the square root of 2?

Answer: sqrt(2)


Which Perl Compatible Regex function takes a regex pattern and an array and returns an array of the elements of the input array that matched the pattern?

Answer: preg_grep


Protected members are available to:

Answer: The class itself and the classes that inherit from it


Which of these variables has an illegal name?

Answer: $your-Var


A(n) _____________ is an ordered map that assigns values to keys:

Answer: array


What PHP type represents a series of characters?

Answer: string


Which of the following is NOT a correct way to specify a string?

Answer: alfanum syntax


Strings in PHP can be specified in four different ways: single quoted, double quoted, heredoc syntax and (since PHP 5.3.0) nowdoc syntax


Which of the following allows you to express any real number?

Answer: double


Which of the following is the correct way to create a reference to a global variable?

Answer: $var =& $GLOBALS[“var”];


Which of the following provides a means to access the same content on PHP variables by different names?

Answer: References


Which PHP operator is used to concatenate strings?

Answer: “.”


What PHP token that allows access to static, constant, and overridden properties or methods of a class?

Answer: ::


Which PHP operator type returns the result of string arguments?)

Answer: String operators


Which of these restrictions applies to namespace implementation?

Answer: Nested namespaces are prohibited.


What term applies to an identifier with a namespace separator that begins with a namespace separator, such as \Foo\Bar?

Answer: Fully qualified name.


Which of the following objects lets you create code which specifies which methods a class must implement, without specifying how the objects are handled?

Answer: Interfaces


Which Interface allows you to use a design pattern that is characteristically changed with the instantiation of objects?

Answer: Instantation Design Interface


Which POSIX character matches the beginning of a string only?

Answer: ^


Which of the following are two broad classes of regular expressions that PHP works with?

Answer: POSIX and PHP-compatible regex


Which statement allows you to end a loop?

Answer: break


This “magic” constant refers to the name of the current namespace and it is defined in compile-time



What is the name for instances of a class that contain all the internal data and state information need for the application to run

Answer: Objects


___________ allows a class to be defined as being a member of more than one category of classes

Answer: Polymorphism


The ability to define a class of one kind as being a subtype of a different kind of class is called:

Answer: Inheritance


Which function changes server parameters and status at runtime?

Answer: Memcache::setServerParams


Which function forces a write of all buffered output to the resource pointed to by the file handle?

Answer: fflush


Single-line comments in PHP use the following:

Answer: //


The ability of a class to protect access to its internal member variables is called:

Answer: encapsulation


You can use what function in order to check if a constant is set?

Answer: defined();


Which of these will perform integer rather than floating point division?

Answer: intval(x/y);


______________ is a mechanism for storing data in the remote browser and thus tracking or identifying return users.

Answer: Cookies


Using the Zip Archive Class, which of the following will include a file to a ZIP archive from a given path?

Answer: zipArchive::addFile


Which of the following is an example of predefined cURL constant?

Answer: All of these







Which of the following refers to a set of functions that allows you have access to multiple supported databases without writing your own wrapper functions?

Answer: PHP DBX


Which of the following is the correct syntax to retrieve an object from the memcache module?

Answer: $result = $memcache->get(‘key’);


_____________ attempts to establish an FTP connection to a remote server by emulating an FTP client.

Answer: FTP ftp_connect()


Which of the following will open the file “time.txt” as readable?

Answer: fopen(“time.txt”,”r”);


Which character must be set in the $mode argument for fopen($file, $mode) to open a file for reading and writing?

Answer: r+;


Which of the following is the correct way to implement a “for” control structure?

Answer: for($i=0; $i<10; $i++){ // do something }


Which of the following is the only keyword that can be written before the namespace at the top of the file?

Answer: declare


What is the correct way to access the property of a PHP object?

Answer: $obj->property


Select the convention sign used to indicate private variables and functions:

Answer: _ for $_name


Arrays can be sorted with which of the following functions?

Answer: arsort(), ksort() and uksort();


Private members are accessible to:

Answer: The class itself and the classes that inherit from it


Which function returns the square root of its argument, with number of decimal places set by the optional scale factor?

Answer: bcsqrt()


What 2 types of parsers are used in PHP?



What does MIME stand for?

Answer: Multipurpose Internet Mail Extensions


Which configuration directive defines a comma separated list of server urls to use for session storage?

Answer: session.save_path


Which function gets permissions for the given file?

Answer: fileperms


Which function checks whether a file or directory exists?

Answer: file_exists


PHP constants:

Answer: All of these


Do not have a dollar sign ($) before them.

May be defined and accessed anywhere without regard to variable scoping rules

May not be redefined or undefined once they have been set.

May only evaluate to scalar values.


Which PHP operator type allows evaluation and manipulation of specific bits within an integer?

Answer: Bitwise operators


At compile time static values are bound with

Answer: a name


Which Perl Compatible Regex character will cause any special character to be treated as a simple matching character?

Answer: \


Session files should not be stored on a directory viewable from the Web server because:

Answer: Malicious users may access other users’ login details


Which API reads in an XML file and creates a “walkable” object tree in memory, so it can be used in large documents?

Answer: DOM


What APIs are used for handling XML documents?

Answer: Document Object Model (DOM) and Simple API for XML (SAX)


________________ tests for the end of file on a file pointer.

Answer: feof()


Instantiate an object Demo: require_once(‘class.Demo.php’);

Answer: $objDemo = new Demo();


Which of the following is correct for adding a comment in a PHP script?

Answer: /* comment */


Which function returns (and caches) file permissions level?

Answer: fileperms(file)


Which PHP function sets file modification time or creates a file if it does not exist?

Answer: touch(file, [time])


Which of these PHP file open modes are valid for the specified conditions?

Answer: All of these


The ____________ function can be used in combination with the PHP header() construct to assemble and send file downloads.

Answer: fpassthru


Which function returns (and caches) the time a file was last accessed?

Answer: fileatime(file)


How do you modify the php.ini file to have sessions work correctly on windows?

Answer: change session.save_path = /tmp to session.save_path=C:/temp


Which function gets statistics from all servers in a pool?

Answer: Memcache::getExtendedStats


Which of the following functions returns a Boolean value after attempting to send a message?

Answer: mail()


Which of the following is the correct way to connect to a MySQL database?

Answer: mysql_connect(“localhost”);


Which files should be used to install cURL in an include directory?

Answer: easy.h and curl.h files


Which function returns the largest number that may be returned by rand()?

Answer: getrandmax()


Which Perl Compatible Regex function inserts escape characters into strings that are intended for use as regex patterns.

Answer: preg_quote


Which of the following shifts the bits of $a $b steps to the left?

Answer: $a << $b


What PHP function returns the arctangent in radians of a numerical argument?

Answer: atan()


Which function is used to start tracking a user?

Answer: session_start();


What statement will delete session files?

Answer: session_destroy();


How are sessions tracked on PHP

Answer: With code rewriting using the PHP Session reference variable


Which statement will skip the rest of the current loop iteration and continue execution at the beginning of next iteration.

Answer: continue


Which function returns (and caches) the owner ID number?

Answer: fileowner()


Which of the following is the correct way to implement a do-while loop?

Answer: $j=0; do { print “$j”; } while ($j > 0);


Which of the following is correct to show a message for an exception?

Answer: throw new Exception (“Invalid data”);


What term refers to the ability to shorten Extra_Long_Names improving readability of source code?

Answer: Aliasing


Which operator performs the same function as x=x%y?

Answer: %=


The control error operator is:

Answer: @


Which of the following is the not equal operator?

Answer: !=


Which Perl Compatible Regex function takes a regex pattern as first argument, a string to match against as second argument, and an optional array variable for returned matches?

Answer: preg_grep


What are the levels of visibility possible for a variable or method?

Answer: Public, Private and Protected


Spread the love
  • 1

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.