Sei sulla pagina 1di 37

1) Mesajul tau:

Ce mai faci?
esti

bine?

Trimite mesajul!

Ce va afisa atunci cand se va aplica nl2br() variabilei ce retine mesajul


din casuta de mai sus?
a) Ce mai faci?
esti
bine?
b)Ce mai faci? esti bine?
c)Ce mai faci?
esti bine?
d)Ce mai faci? Esti bine?

Corect: c)

2)Ce fac functiile htmlentities() si strip_tags();


a)prima inlatura doar tagurile html si a doua doar tagurile php
b)prima inlatura doar tagurile php si a doua doar tagurile html
c)prima inlatura doar tagurile html si a doua doar tagurile html
+tagurile php
d)prima inlatura doar tagurile html si a doua doar tagurile
html+tagurile CSS

Corect.C

3)htmlentities() si strip_tags() au ca scop:


a)protejarea de atacuri XSS(cross-site scripting)
b)protejarea de atacuri de malware
c)criptarea parolelor utilizatorilor
d)protectia impotriva duplicarii conturilor de utilizatori(boti de
advertising)

Correct:A

3)Ce va afisa urmatoarea secventa de cod:


#var1=abcdefgh;
#var2=a;
echo strcmp($var1,$var2);
a)7 b)0 c)1 d)8

Correct a)var1>var2(cu 7 caractere, !!! sirul var2 trebuie sa fie


la inceputul lui var1)

4) $var1="abcdefghijklmnopdqrstuvwxyz";

echo strstr($var1,j,true);
a)abcdefghij
b)abcdefghi
c)jklmnopqrstuvwxyz
d)klmnopdqrstuvwxyz

Correct-b)

strstr(string,search,before_search)

string

Required. Specifies the string to search

search

Required. Specifies the string to search for. If this parameter is a number, it will
character matching the ASCII value of the number

before_searc
h

Optional. A boolean value whose default is "false". If set to "true", it returns the
before the first occurrence of the search parameter.

5) $vara="abcdefgh";
$varb="bc";

Echo strops($vara,$varb,1);
a)1 b)0 c)null d)true e)2

Corect a)
strpos(string,find,start)
string

Required. Specifies the string to search

find

Required. Specifies the string to find

start

Optional. Specifies where to begin the search

6) $varabc="ce mai faci mai baiete de umbli cu curca pe


strada";
echo strtok($varabc," ");

a)ce
b)cemai
c)cemaifacimaibaietedeumblicucurcapestrada
d)ce mai faci

Correct)a

strtok(string,split)
string

Required. Specifies the string to split

split

Required. Specifies one or more split characters

**daca este apelat iar este de ajuns sintaxa strtok(" "); si va


mai face inca o separare din ce a rams din sir si va afisa: mai.
Se utilizeaza foarte bine in bucle while pentru a putea sparge un
text mai lung in bucatele mai mici in functie de un anumit
caracter(de exemplu dupa spatiu)

7) $vara="abcdefgh";

echo substr($vara,3,3);
a)def
b)cde
c)defgh
d)cdefg

Correct)a
substr(string,start,length)

string

Required. Specifies the string to return a part of

start

Required. Specifies where to start in the string

length

A positive number - Start at a specified position in the string

A negative number - Start at a specified position from the end of the string

0 - Start at the first character in string

Optional. Specifies the length of the returned string. Default is to the end of the string

A positive number - The length to be returned from the start parameter

Negative number - The length to be returned from the end of the string

// Positive numbers:
echo substr("Hello world",10)."<br>";
echo substr("Hello world",1)."<br>";
echo substr("Hello world",3)."<br>";
echo substr("Hello world",7)."<br>";
echo "<br>";
// Negative numbers:
echo substr("Hello world",-1)."<br>";
echo substr("Hello world",-10)."<br>";
echo substr("Hello world",-8)."<br>";
echo substr("Hello world",-4)."<br>";

d
ello world
lo world
orld
d
ello world
lo world
orld

// Positive numbers:
echo substr("Hello world",0,10)."<br>";
echo substr("Hello world",1,8)."<br>";
echo substr("Hello world",0,5)."<br>";
echo substr("Hello world",6,6)."<br>";
echo "<br>";
// Negative numbers:
echo substr("Hello world",0,-1)."<br>";
echo substr("Hello world",-10,-2)."<br>";
echo substr("Hello world",0,-6)."<br>";
echo substr("Hello world",-2-3)."<br>";

Hello worl
ello wor
Hello
world
Hello worl
ello wor
Hello
world

8)Care dintre urmatoarele variante reprezinta solutia pentru a


capitaliza prima litera a fiecarui cuvant dintr-un string?
a)ucfirst()
b)ucwords()
c)strtoupper()
d)strtolower()

a)-doar prima litera


b)correct
c)tot stringul litera mare
d)tot stringul litera mica

9) $var32='abcbcedadaa';
echo str_ireplace('a','zzz',$var32,$elemente);

echo $elemente;
a) zabcbcedadaa si 1
b) zzzbcbcedzzzdzzzzzz si 12
c) zzzbcbcedzzzdzzzzzz si 3
d) zzzbcbcedzzzdzzzzzz si 4

10)str_ireplace(find,replace,string,count)(str_replace-case
sensitive)

find

Required. Specifies the value to find

replace

Required. Specifies the value to replace the value in find

string

Required. Specifies the string to be searched

count

Optional. A variable that counts the number of replacements

11) $var32='abc
echo $var32;

def gfr rre //!!! ';

a) abc def gfr


b) abc def gfr
c) 'abc def
d) 'abc def

rre //!!!
rre
gfr rre
gfr rre //!!!

Corect a) Mai sunt ltrim() sir trim()-sterg la stanga si la dreapta


<?php
$str = "Hello World!";

echo $str . "<br>";


echo trim($str,"Hed!");
?>

Hello World!
llo Worl

12)Variabile booleane ,inPHP, sunt case-insensitive?


a)true
b)FALSE

a)true

13)Care dintre urmatoarele variante este valabila ca sintaxa


pentru IF?
a) if(cond) statement;
b) if(cond) {
statement
}

c) if(cond) { statement }
d) if(cond)
statement

13)a,b si c

14)

$var1=0;
$var2= something;
$var3= ;

Empty($var); Empty($var1);
a)true true true true

Empty($var2);

Empty($var3);

b)false true true true


c)true true false true
d)true false false true
e)false false true fasle

Correct c)- daca exista ceva in variabila atunci afiseaza false,


daca nu, afiseaza true
Daca variabila nu exista afiseaza true

15)

$var1=0;
$var2= something;
$var3= ;

isset($var); isset ($var1);


a)true true true true
b)false false false false
c)true true false true

isset ($var2); isset ($var3);

d)true false false true


e)false true true true

Correct e)false true true true


Daca variabila exista, atunci avem true ,else false

16)

$var1=0;
$var2= something;
$var3= 342;

Is_numeric($var); is_numeric($var1);
is_numeric($var3);
a)true true true true
b)false false false false
c)true true false true
d)true false false true

is_numeric($var2);

e)false true false true

Corect e)doar ce sunt numere returneaza true, 0 si 342

17)Cati parametric poate lua functia ISSET


a)1
b)2
c)Cati sunt nevoie
d)maxim 2

Correct a)b)c)- daca oricare dintre acestia este evaluat ca false


atunci toate constructia va deveni false

18)Cum vor fi evaluate urmatoarele sintaxe:


$var=false;
If ($var))
If (!$var))
If (isset($var))
If (!isset($var))
If (!empty($var))
a)true true false true true
b)true false true false true
c)true true true true false
d)true false true true true

Correct:b)true false true false true