Monday, June 19, 2017

Design Patterns PHP

DesignPatternsPHPThis is a collection of known design patterns and some sample code how to implement them in PHP. Every pattern has a small list of examples (most of them from Zend Framework, Symfony2 or Doctrine2 as I’m most familiar with this software).
I think the problem with patterns is that often people do know them but don’t know when to apply which.

Friday, June 16, 2017

MySQL 5.6 Reference Manual

MySQL Database Tutorial - 1 - Introduction to Databases 
MySQL Database Tutorial - 2 - Getting a MySQL Server 
MySQL Database Tutorial - 5 - Basic Rules for SQL Statements 
MySQL Database Tutorial - 6 - Getting Multiple Columns 
MySQL Database Tutorial - 7 - DISTINCT and LIMIT 
MySQL Database Tutorial - 8 - Sorting Results 

MySQL Database Tutorial - 9 - Sort Direction 
MySQL Database Tutorial - 10 - Basic Data Filtering and WHERE 
MySQL Database Tutorial - 11 - Advanced Filtering Using AND and OR 
MySQL Database Tutorial - 12 - Are you IN or are you NOT IN? 
MySQL Database Tutorial - 13 - How Search Engines Work 
MySQL Database Tutorial - 14 - More on Wildcards 
MySQL Database Tutorial - 15 - Regular Expressions 
MySQL Database Tutorial - 16 - Creating Custom Columns 
MySQL Database Tutorial - 17 - Functions 
MySQL Database Tutorial - 18 - More on Aggregate Functions 
MySQL Database Tutorial - 19 - GROUP BY 
MySQL Database Tutorial - 20 - Subqueries 
MySQL Database Tutorial - 21 - Another Subquery Example 
MySQL Database Tutorial - 22 - How to Join Tables 
MySQL Database Tutorial - 23 - Outer Joins 
MySQL Database Tutorial - 24 - UNION 
MySQL Database Tutorial - 25 - Full-Text Searching 
MySQL Database Tutorial - 26 - INSERT INTO 
MySQL Database Tutorial - 27 - How to Insert Multiple Rows 
MySQL Database Tutorial - 28 - UPDATE & DELETE 
MySQL Database Tutorial - 29 - CREATE TABLE 
MySQL Database Tutorial - 30 - NOT NULL & AUTO INCREMENT 
MySQL Database Tutorial - 31 - ALTER / DROP / RENAME TABLE 
MySQL Database Tutorial - 32 - Views 
MySQL Database Tutorial - 33 - Final Video! 

Monday, June 5, 2017

Zend Certified PHP Engineer Exam: 200-550

What is the output of the following code? echo '1' . (print '2') + 3;

A. 123
B. 213
C. 142
D. 214
E. Syntax error

Answer: D
What is the output of the following code?
$a = 3; switch ($a) {
case 1: echo 'one'; break; case 2: echo 'two'; break; default: echo 'four'; break; case 3: echo 'three'; break;

A. one B. two C. three D. four
Answer: C

What is "instanceof" an example of?
A. a boolean
B. an operator
C. a function
D. a language construct E. a class magic

Answer: B QUESTION: 4
Which of the following may be used in conjunction with CASE inside a SWITCH statement?
A. A scalar
B. An expression 

C. A boolean
D. All of the above

Answer: D
What is the output of the following code? $a = 'a'; $b = 'b';
echo isset($c) ? $a.$b.$c : ($c = 'c').'d';

A. abc B. cd C. Od
Answer: B

Which of the following are valid identifiers? (Choose 3)
A. function 4You() { } B. function _4You() { } C. function object() { } D. $1 = "Hello";
E. $_1 = "Hello World"; Answer: B, C, E

What super-global should be used to access information about uploaded files via a POST request?

E. $_GETAnswer: D

What is the difference between "print" and "echo"?

A. There is no difference.
B. Print has a return value, echo does not
C. Echo has a return value, print does not
D. Print buffers the output, while echo does not E. None of the above

Answer: B QUESTION: 9
What is the output of the following code? echo "1" + 2 * "OxO2";
A. 1 B. 3 C. 5 D. 2O E. 7
Answer: C

What is the result of the following bitwise operation in PHP? 1 ^ 2
A. 1 B. 3 C. 2 D. 4 E. -1 
Answer: B
What is the output of the following code? echo "22" + "O.2", 23 . 1;

A. 22O.2231 B. 22.2231 C. 22.2,231 D. 56.2
Answer: B
What is the output of the following code? $first = "second";
$second = "first"; echo $$$first;

A. "first"
B. "second"
C. an empty string D. an error

Answer: B

Your supervisor wants you to disallow PHP scripts to open remote HTTP and FTP resources using PHP's file functions. Which php.ini setting should you change accordingly?

Answer:  allow_url_fopen = Off

Which of the following code snippets DO NOT write the exact content of the file "source.txt" to "target.txt"? (Choose 2)
A. file_put_contents("target.txt", fopen("source.txt", "r"));
B. file_put_contents("target.txt", readfile("source.txt"));
C. file_put_contents("target.txt", join(file("source.txt"), "\n"));
D. file_put_contents("target.txt", file_get_contents("source.txt"));
E. $handle = fopen("target.txt", "w+"); fwrite($handle, file_get_contents("source.txt")); fclose($handle);

Answer: B, C

What is the recommended method of copying data between two opened files?
A. copy($source_file, $destination_file);
B. copy($destination_file, $source_file);
C. stream_copy_to_stream($source_file, $destination_file); D. stream_copy_to_stream($destination_file, $source_file); E. stream_bucket_prepend($source_file, $destination_file);

Answer: C

Which of the following will set a 1O seconds read timeout for a stream?
A. ini_set("default_socket_timeout", 1O);
B. stream_read_timeout($stream, 1O);
C. Specify the timeout as the 5th parameter to the fsockopen() function used to open a stream
D. stream_set_timeout($stream, 1O);
E. None of the above

Answer: D

What function allows resizing of PHP's file write buffer?
A. ob_start()
B. set_write_buffer()
C. stream_set_write_buffer()
D. Change the output_buffering INI setting via ini_set() function

Answer: C

What does the FILE constant contain?
A. The filename of the current script. B. The full path to the current script. C. The URL of the request made.
D. The path to the main script.

Answer: B

What can prevent PHP from being able to open a file on the hard drive (Choose 2)?
A. File system permissions
B. File is outside of open_basedir C. File is inside the /tmp directory. D. PHP is running in CGI mode.

Answer: A, B

What purpose do namespaces fulfill?
A. Encapsulation
B. Alternative to classes C. Improved performance D. All of the above
Answer: A

image magic resize image with fix width and height and white background command

convert big.jpg -resize 1280X680 -background white -gravity center -extent 1280x680 big1.jpg 

Laravel Interview questions and answers

1. What is Laravel Laravel is free open source “PHP framework” based on MVC Design Pattern . It is created by Taylor Otwell. Laravel pro...