13
PREPARATÓRIO CERTIFICAÇÃO PHP5 40 Horas Instrutor: Antonio Itamar Júnior

Preparatório certificação php5

  • Upload
    taariq

  • View
    41

  • Download
    0

Embed Size (px)

DESCRIPTION

Preparatório certificação php5. 40 Horas Instrutor: Antonio Itamar Júnior. Strings and Regular Expressions. - Declaração de classe - Nomenclatura - Instanciar classe - Utilizar atributos e métodos de classe. Strings and Regular Expressions. - PowerPoint PPT Presentation

Citation preview

Page 1: Preparatório certificação php5

PREPARATÓRIO CERTIFICAÇÃO PHP540 Horas

Instrutor: Antonio Itamar Júnior

Page 2: Preparatório certificação php5

STRINGS AND REGULAR EXPRESSIONS

- Declaração de classe

- Nomenclatura

- Instanciar classe

- Utilizar atributos e métodos de classe

Page 3: Preparatório certificação php5

STRINGS AND REGULAR EXPRESSIONSSTRINGS ARE THE SWISS-ARMY knife of PHP, particularly if you consider the fact that

most PHP scripts are used to serve web pages—which are, for the most part, nothing more than

large strings. Knowing how to use this particular facility is, therefore, one of the most

fundamental skills of the PHP developer, since you’ll be working with them day in and day out.

Luckily, its essential role in the life of a PHP script has resulted in string manipulation

being made exceptionally easy by the PHP development team. Therefore, once you get past the

first few hurdles, handling strings becomes easy, quick and—to some extent—even fun.

However, this particular aspect of PHP programming is far from being free of pitfalls. This

portion of the exam tests your understanding of strings as well as your knowledge of the body of

functions that are used to manipulate them. Additionally, you’ll find yourself faced with the

basics of that most voodoo art of writing regular expressions, which, despite being a hugely

useful tool, is too often neglected by most developers.3

Page 4: Preparatório certificação php5

QUESTÃO 1

Consider the following script. What line of code should be inserted in the marked location in order to display the string php when this script is executed?

“Considere o seguinte script. Qual linha de código deve ser inserida no local marcado para exibir a string php quando esse script for executado?”

A. echo chr($val);

B. echo asc($val);

C. echo substr($alpha, $val, 2);

D. echo $alpha{$val};

E. echo $alpha{$val+1}4

<?php $alpha = 'abcdefghijklmnopqrstuvwxyz'; $letters = array( 15 , 7 , 15 ); foreach( $letters as $val ) { /* What should be here */ }?>

Page 5: Preparatório certificação php5

QUESTÃO 2

Which of the following will not combine strings $s1 and $s2 into a single string?

“Qual das seguintes variáveis não irá combinar strings $s1 e $s2 em uma única string?”

A. $s1 + $s2

B. "{$s1}{$s2}"

C. $s1.$s2

D. implode('', array($s1,$s2))

E. All of the above combine the strings

ExplicaçãoCom exceção da resposta A, todas as repostas produzirão o resultado desejado de concatenação das strings $s1 com $s2. No PHP, o operador mais (+) não combina duas strings juntas, como acontece em outras línguas, tais como Java e Javascript.

5

Page 6: Preparatório certificação php5

QUESTÃO 3

Given a variable $email containing the string [email protected], which of the following statements would extract the string example.com?

“Dada uma variável $ email contendo a string [email protected], qual das seguintes declarações seria extrair a seqüência example.com?”

A. substr($email, strpos($email, "@"));

B. strstr($email, "@");

C. strchr($email, "@");

D. substr($email, strpos($email, "@")+1);

E. strrpos($email, "@");

ExplicaçãoA funçao substr é usada para retornar uma parte de um texto, enquanto a função strpos é usada para encontrar uma determinada substring dentro de uma string. Utilizado em conjunto, podemos extrair a informação exigida.

É importante perceber que é ex-zero-indexados, enquanto o último não é,

1 exigindo uma compensação a ser adicionado. É por isso que a resposta D é correto.

6

Page 7: Preparatório certificação php5

MANIPULATING FILES

- Manipulação de Arquivos

- 20 questões

Page 8: Preparatório certificação php5

MANIPULATING FILESTHOUGH YOU MAY NEVER think of file manipulation as one PHP’s strengths, it is actually a

very useful tool for the developer. Even if you only develop websites, being able to read from

and write to a file can turn out to be a very handy capability. After all, remember that, thanks to

its stream wrappers (covered in more detail in Chapter 10), PHP makes it possible to open a

remote file and read from it—useful, for example, for including content from a third-party site.

On a more basic level, however, file input/output can be used for a multitude of tasks. For

example, it’s handy for reading and interpreting the contents of a preformatted file, such as you

could receive from a third-party provider sending you syndicated content, or for opening up and

outputting binary files to the browser through your scripts so that you can more tightly control

access to them. Whatever the end use, you will be tested not only on the basics of opening,

closing and accessing a file’s contents, but also on fundamental aspects of file manipulation that

are relevant in a multi-process environment, such as file locking.

8

Page 9: Preparatório certificação php5

QUESTÃO 1

The _______ function is used to read a single line from a file and is used when dealing with text files. For reading binary data or other specific segments of a file, you should use the _______ function instead.

“_______ A função é usada para ler uma única linha de um arquivo e é usado quando se lida com arquivos de texto. Para leitura de dados binários ou outros segmentos específicos de um arquivo, você deve usar o _______ Função vez.”

A. fgets(), fseek()

B. fread(), fgets()

C. fputs(), fgets()

D. fgets(), fread()

E. fread(), fseek()

9

Page 10: Preparatório certificação php5

QUESTÃO 2

Although file resources will automatically be closed at the end of a request in PHP, you can close them explicitly by calling the _______ function.

Your Answer: ____________________________

10

Page 11: Preparatório certificação php5

QUESTÇÃO 3

Consider the following PHP script, which reads a file, line-by-line, from a text file. Which function call should be inserted in place of the question marks in order for the script to function correctly?

11

Page 12: Preparatório certificação php5

QUESTÃO 4 Which of the following techniques will guarantee a lock safe from any

race condition?

12

Page 13: Preparatório certificação php5

REFERÊNCIA BIBLIOGRÁFICAS PHP

http://www.php.net Zend.PHP.5.Certification.Study.Guide.2006 The_Zend_PHP_Certification_Practice_Test_Book

MySQL http://www.mysql.com [acessado em 1 de maio de 2009 as 21Hrs] http://dev.mysql.com [acessado em 1 de maio de 2009 as 20Hrs] http://www.w3schools.com/sql [acessado em 1 de maio de 2009 as 21Hrs]

13