\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Lilava} \pdfinfo{ /Title (mix-php-2.pdf) /Creator (Cheatography) /Author (Lilava) /Subject (Mix PHP 2 Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{A35894} \definecolor{LightBackground}{HTML}{F9F4F8} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Mix PHP 2 Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Lilava} via \textcolor{DarkBackground}{\uline{cheatography.com/64138/cs/16332/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Lilava \\ \uline{cheatography.com/lilava} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 12th July, 2018.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{bitwise}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{What is the result of the following bitwise operation in PHP? \newline % Row Count 2 (+ 2) 1 \textasciicircum{} 2 \newline % Row Count 3 (+ 1) A. 1 \newline % Row Count 4 (+ 1) B. 3 \newline % Row Count 5 (+ 1) C. 2 \newline % Row Count 6 (+ 1) D. 4 \newline % Row Count 7 (+ 1) E. -1% Row Count 8 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: B} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{date}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Which of the following will NOT instantiate a DateTime object with the current timestamp? \newline % Row Count 2 (+ 2) A. \$date = new DateTime(); \newline % Row Count 3 (+ 1) B. \$date = new DateTime('@' . time()); \newline % Row Count 4 (+ 1) C. \$date = new DateTime('now'); \newline % Row Count 5 (+ 1) D. \$date = new DateTime(time());% Row Count 6 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: D} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{date}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Given the following DateTime object, which sample will NOT alter the date to the value '2014-02-15'? \newline % Row Count 3 (+ 3) \$date = new DateTime('2014-03-15'); \newline % Row Count 4 (+ 1) A. \$date-\textgreater{}sub(new DateInterval('P1M')); \newline % Row Count 6 (+ 2) B. \$date-\textgreater{}setDate(2014, 2, 15); \newline % Row Count 7 (+ 1) C. \$date-\textgreater{}modify('-1 month'); \newline % Row Count 8 (+ 1) D. \$date-\textgreater{}diff(new DateInterval('-P1M'));% Row Count 10 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: D} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{pdo}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Which of these databases is NOT supported by a PDO driver? \newline % Row Count 2 (+ 2) A. Microsoft SQL Server \newline % Row Count 3 (+ 1) B. SQLite \newline % Row Count 4 (+ 1) C. Microsoft Access \newline % Row Count 5 (+ 1) D. Berkeley DB% Row Count 6 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: D} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{object}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{An object can be counted with count() and sizeof() if it... \newline % Row Count 2 (+ 2) A. implements ArrayAccess \newline % Row Count 3 (+ 1) B. has a public \_\_count() method \newline % Row Count 4 (+ 1) C. was cast to an object from an array \newline % Row Count 5 (+ 1) D. None of the above% Row Count 6 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: D} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{class}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Which of the following statements about PHP is false? (Choose 2) \newline % Row Count 2 (+ 2) A. A final class can be derived. \newline % Row Count 3 (+ 1) B. A final class may be instantiated. \newline % Row Count 4 (+ 1) C. A class with a final function may be derived. \newline % Row Count 5 (+ 1) D. Static functions can be final. \newline % Row Count 6 (+ 1) E. Properties can be final.% Row Count 7 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: A, E} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{class}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{When a class is defined as final it: \newline % Row Count 1 (+ 1) A. Can no longer be extended by other classes. \newline % Row Count 2 (+ 1) B. Means methods in the class are not over-loadable. \newline % Row Count 4 (+ 2) C. Cannot be defined as such, the final is only applicable to object methods. \newline % Row Count 6 (+ 2) D. Cannot be instantiated.% Row Count 7 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: A} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{arrays}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Which value will be assigned to the key 0 in this example? \newline % Row Count 2 (+ 2) \$foo = array(true, '0' =\textgreater{} false, false =\textgreater{} true);% Row Count 3 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: true} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{arrays}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Which is the most efficient way to determine if a key is present in an array, assuming the array has no NULL values? \newline % Row Count 3 (+ 3) A. in\_array('key', array\_keys(\$a)) \newline % Row Count 4 (+ 1) B. isset(\$a{[}'key'{]}) \newline % Row Count 5 (+ 1) C. array\_key\_exists('key', \$a) \newline % Row Count 6 (+ 1) D. None of the above% Row Count 7 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: B} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{string}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{What is the length of a string returned by: md5(rand(), TRUE); \newline % Row Count 2 (+ 2) A. Depends on the value returned by rand() function \newline % Row Count 4 (+ 2) B. 32 \newline % Row Count 5 (+ 1) C. 24 \newline % Row Count 6 (+ 1) D. 16 \newline % Row Count 7 (+ 1) E. 64% Row Count 8 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: D} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Namespace}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{When Would you use classes and when would you use namespaces\textgreater{} \newline % Row Count 2 (+ 2) A. Use classes to encapsulate code and represent objects, and namespaces to avoid symbol name collision \newline % Row Count 5 (+ 3) B. Use Classes for performance-sensitive code, namespaces when readability maters more \newline % Row Count 7 (+ 2) C. Use namespaces for performance-sensitive code, and classes when readability matters more \newline % Row Count 10 (+ 3) D. Always use them; namespaces are always superior to classes% Row Count 12 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: A} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Namespace}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{What purpose do namespaces fulfill? \newline % Row Count 1 (+ 1) A. Encapsulation \newline % Row Count 2 (+ 1) B. Alternative to classes \newline % Row Count 3 (+ 1) C. Improved performance \newline % Row Count 4 (+ 1) D. All of the above% Row Count 5 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: A} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Namespace}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{What would be the output of the following code? \newline % Row Count 1 (+ 1) namespace MyFramework\textbackslash{}DB; \newline % Row Count 2 (+ 1) class MyClass \{ \newline % Row Count 3 (+ 1) static function myName() \{ \newline % Row Count 4 (+ 1) return \_\_METHOD\_\_; \newline % Row Count 5 (+ 1) print MyClass::myName(); \newline % Row Count 6 (+ 1) A. MyFramework\textbackslash{}DB\textbackslash{}myName \newline % Row Count 7 (+ 1) B. MyFramework\textbackslash{}DB\textbackslash{}MyClass\textbackslash{}myName \newline % Row Count 8 (+ 1) C. MyFramework\textbackslash{}DB\textbackslash{}MyClass::myName \newline % Row Count 9 (+ 1) D. MyClass::myName% Row Count 10 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: C} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Namespace}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{You'd like to use the class MyDBConnection that's defined in the \newline % Row Count 2 (+ 2) MyGreatFramework\textbackslash{}MyGreatDatabaseAbstractionLayer namespace, but you want to minimize as much as possible the length of the class name you have to type. What would you do? \newline % Row Count 6 (+ 4) A. Import the MyGreatFramework namespace \newline % Row Count 7 (+ 1) B. Import the MyGreatFramework\textbackslash{}MyGreatDatabaseAbstractionLayer namespace \newline % Row Count 9 (+ 2) C. Alias MyGreatFramework\textbackslash{}MyGreatDatabaseAbstractionLayer\textbackslash{}MyDBConnection to a shorter name \newline % Row Count 12 (+ 3) D. Alias MyGreatFramework\textbackslash{}MyGreatDatabaseAbstractionLayer to a shorter name% Row Count 15 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: C} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Namespace}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Which of these elements can be encapsulated by namespaces and made accessible from \newline % Row Count 2 (+ 2) the outside? \newline % Row Count 3 (+ 1) A. Only classes \newline % Row Count 4 (+ 1) B. Classes, functions, and constants \newline % Row Count 5 (+ 1) C. Classes, functions, constants, and variables% Row Count 6 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: B} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Class Constants}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Which of the following statements is NOT true? \newline % Row Count 1 (+ 1) A. Class constants are public \newline % Row Count 2 (+ 1) B. Class constants are being inherited \newline % Row Count 3 (+ 1) C. Class constants can omit initialization (default to NULL) \newline % Row Count 5 (+ 2) D. Class constants can be initialized by const% Row Count 6 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: C} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{conjuction}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Which of the following may be used in conjunction with CASE inside a SWITCH statement? \newline % Row Count 2 (+ 2) A. A scalar \newline % Row Count 3 (+ 1) B. An expression \newline % Row Count 4 (+ 1) C. A boolean \newline % Row Count 5 (+ 1) D. All of the above% Row Count 6 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: D} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{php}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Given the default PHP configuration, how can all of the parameters provided via GET be accessed in a form of a string? \newline % Row Count 3 (+ 3) A. \$\_GET{[}'ALL'{]} \newline % Row Count 4 (+ 1) B. \$\_SERVER{[}'QUERY'{]} \newline % Row Count 5 (+ 1) C. \$\_SERVER{[}'QUERY\_STRING'{]} \newline % Row Count 6 (+ 1) D. \$\_ENV{[}'QUERY'{]} \newline % Row Count 7 (+ 1) E. \$QUERY\_STRING% Row Count 8 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: C} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{pdo}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Which of these statements about PDO is NOT true? \newline % Row Count 1 (+ 1) A. PDO has built-in support for Large Objects (LOBs). \newline % Row Count 3 (+ 2) B. Placeholders within PDO prepared statements need to be named. \newline % Row Count 5 (+ 2) C. When something goes wrong, PDO can throw an instance of its own exception class. \newline % Row Count 7 (+ 2) D. PDO does not emulate missing database features.% Row Count 8 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: B} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{PHP}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{When retrieving data from URLs, what are valid ways to make sure all file\_get\_contents calls send a certain user agent string? (Choose 2) \newline % Row Count 3 (+ 3) A. \$default\_opts =array('http' =\textgreater{}array('user\_agent' =\textgreater{} "My Cool Brower"));\$default= \seqsplit{stream\_context\_set\_default(\$default\_opts);} \newline % Row Count 7 (+ 4) B. \seqsplit{stream\_context\_set\_option("user\_agent"}, "My Cool Browser"); \newline % Row Count 9 (+ 2) C. ini\_set('user\_agent' , "My Cool Browser"); \newline % Row Count 11 (+ 2) D. \seqsplit{stream\_context\_set\_option(\$context}, "http", "user\_agent", "My Cool Browser");% Row Count 14 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: A, C} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{PHP}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Which of the following PHP values may NOT be encoded to a JavaScript literal using \newline % Row Count 2 (+ 2) PHP's ext/json capabilities? \newline % Row Count 3 (+ 1) A. 'Hello, world!' \newline % Row Count 4 (+ 1) B. function()\{ alert("Hello, world!"); \} \newline % Row Count 5 (+ 1) C. array('Hello, world!') \newline % Row Count 6 (+ 1) D. array('message' =\textgreater{} 'Hello, world!')% Row Count 7 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: B} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{PHP}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Please provide the value of the \$code variable in the following statement to set an HTTP \newline % Row Count 2 (+ 2) status code that signifies that the requested resource was not found. \newline % Row Count 4 (+ 2) \seqsplit{http\_response\_code(\$code);}% Row Count 5 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: 404, 404 Not Found} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{PHP}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Consider the following two files. When you run test.php , what would the output look like? \newline % Row Count 2 (+ 2) test.php: \newline % Row Count 3 (+ 1) include "MyString.php"; \newline % Row Count 4 (+ 1) print ","; \newline % Row Count 5 (+ 1) print strlen("Hello World"); \newline % Row Count 6 (+ 1) MyString.php: \newline % Row Count 7 (+ 1) namespace MyFramework\textbackslash{}String: \newline % Row Count 8 (+ 1) function strlen(\$str) \newline % Row Count 9 (+ 1) return\textbackslash{}strlen(\$str) *2; // return double the string length \newline % Row Count 11 (+ 2) print strlen ("Hello World") \newline % Row Count 12 (+ 1) A. 12.12 \newline % Row Count 13 (+ 1) B. 12,24 \newline % Row Count 14 (+ 1) C. 24.12 \newline % Row Count 15 (+ 1) D. 24,24 \newline % Row Count 16 (+ 1) E. PHP Fatal error:cannot declare strlen()% Row Count 17 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: C} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{PHP}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{What is the benefit of using persistent database connections in PHP? (Choose two.) \newline % Row Count 2 (+ 2) A. Reduces the connection \& authentication overhead of connecting to the database \newline % Row Count 4 (+ 2) B. Ensures that only a single connection is open to the database from PHP \newline % Row Count 6 (+ 2) C. Allows connection settings such as character set encoding to persist \newline % Row Count 8 (+ 2) D. Allows for a resumption of transactions across multiple requests.% Row Count 10 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: C, D} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{PHP}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Which of the following is used to find all PHP files under a certain directory? \newline % Row Count 2 (+ 2) A. PHPIterator \newline % Row Count 3 (+ 1) B. RecursiveTreeIterator \newline % Row Count 4 (+ 1) C. \seqsplit{RecursiveDirectoryIterator} \newline % Row Count 5 (+ 1) D. SplTempFileObject% Row Count 6 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: C} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{PHP}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{What is the difference between "print" and "echo"? \newline % Row Count 2 (+ 2) A. There is no difference. \newline % Row Count 3 (+ 1) B. Print has a return value, echo does not \newline % Row Count 4 (+ 1) C. Echo has a return value, print does not \newline % Row Count 5 (+ 1) D. Print buffers the output, while echo does not \newline % Row Count 6 (+ 1) E. None of the above% Row Count 7 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: B} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{PHP}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Which of the following statements is true? \newline % Row Count 1 (+ 1) A. All PHP database extensions support prepared statements \newline % Row Count 3 (+ 2) B. All PHP database extensions come with their own special helper functions to escape user data to be used in dynamic SQL queries \newline % Row Count 6 (+ 3) C. All PHP database extensions provide an OOP interface \newline % Row Count 8 (+ 2) D. All PHP database extensions appear in the output of php -m , if installed and enabled% Row Count 10 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: D} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{PHP}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{What is the pattern modifier for handling UTF-8 encoded preg\_ *functionality? \newline % Row Count 2 (+ 2) A. e \newline % Row Count 3 (+ 1) B. u \newline % Row Count 4 (+ 1) C. PHP does not support UTF-8 encoded strings \newline % Row Count 5 (+ 1) D. a pattern modifier is not needed% Row Count 6 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: B} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{PHP}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{What is "instanceof" an example of? \newline % Row Count 1 (+ 1) A. a boolean \newline % Row Count 2 (+ 1) B. an operator \newline % Row Count 3 (+ 1) C. a function \newline % Row Count 4 (+ 1) D. a language construct \newline % Row Count 5 (+ 1) E. a class magic% Row Count 6 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: B} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{php.ini}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Given a php.ini setting of \newline % Row Count 1 (+ 1) default\_charset = utf-8 \newline % Row Count 2 (+ 1) what will the following code print in the browser? \newline % Row Count 4 (+ 2) header('Content-Type: text/html; charset=iso-8859-1'); \newline % Row Count 6 (+ 2) echo '✂✔✝'; \newline % Row Count 7 (+ 1) A. Three Unicode characters, or unreadable text, depending on the browser \newline % Row Count 9 (+ 2) B. \seqsplit{\&\#9986;\&\#10004;\&\#10013;} \newline % Row Count 10 (+ 1) C. A blank line due to charset mismatch% Row Count 11 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: A} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{php.ini}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Your supervisor wants you to disallow PHP scripts to open remote HTTP and FTP \newline % Row Count 2 (+ 2) resources using PHP's file functions. Which php.ini setting should you change accordingly?% Row Count 4 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer : allow\_url\_fopen, allow\_url\_fopen=off, allow\_url\_fopen=Off, allow\_url\_fopen = off, allow\_url\_fopen = Off} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{php.ini}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Which php.ini setting is usually required to use an opcode cache? \newline % Row Count 2 (+ 2) A. extension \newline % Row Count 3 (+ 1) B. zend\_extension \newline % Row Count 4 (+ 1) C. optimizer \newline % Row Count 5 (+ 1) D. dl% Row Count 6 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Answer: B} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}