PHP Flashcards
PHP is a _________
server scripting language
PHP is an acronym for ________
“PHP: Hypertext Preprocessor”
PHP code is executed on the _____, and the result is returned to the browser as plain HTML
server
PHP can generate _______ page content.
PHP can collect _______
PHP can send and receive _____
PHP can ____ data
dynamic
form data
cookies
encrypt
PHP can add, delete, _____ data in your database.
PHP can ____, open, read, write, ____, and close files on the server
modify
create, delete
To check your php version you can use the ________ function:
phpversion()
echo phpversion();
A PHP script starts with ____ and ends with ?>
<?php
<?php
// PHP code goes here
?>
PHP statements end with a _________
semicolon (;)
All variable names are ________
case-sensitive!
Comments
Single line: // or ____
Multiline comment: _____
#
/* This is a multi-line comment */
In PHP, a variable starts with the ___ sign, followed by the name of the variable:
$
$x = 5;
$y = “John”
To get the data type of a variable, use the ________ function.
var_dump()
$x = 5;
var_dump($x);
int(5)
A variable declared ______ a function has a GLOBAL SCOPE and can only be accessed outside a function:
outside
A variable declared _____ a function has a LOCAL SCOPE and can only be accessed within that function:
within
With PHP, there are two basic ways to get output: ____ and _____.
echo and print
echo “Hello world!”;
_____ “Hello world!”;
print “Hello world!”;
The var_dump() function returns the ________ and the _______
data type , value
$x = 59;
var_dump($x);
int(59)
The PHP _____ function returns the length of a string.
strlen()
echo strlen(“Hello world!”);
The PHP ___________function counts the number of words in a string.
str_word_count()
echo str_word_count(“Hello world!”);
he PHP _______ function searches for a specific text within a string.
strpos()
echo strpos(“Hello world!”, “world”);
output: 6
The _______ function returns the string in upper case:
strtoupper()
echo strtoupper($x);
The ________ function returns the string in lower case:
strtolower()
echo strtolower($x);
The PHP _______ function replaces some characters with some other characters in a string.
str_replace()
$x = “Hello World!”;
echo str_replace(“World”, “Dolly”, $x);
Output: Hello Dolly!
The PHP ______ function reverses a string.
strrev()
echo strrev($x);
The ______ removes any whitespace from the beginning or the end:
trim()
echo trim($x);
The PHP _____ function splits a string into an array.
The first parameter of the explode() function represents the “______”. The “_______” specifies where to split the string.
explode()
separator, separator
$x = “Hello World!”;
$y = explode(“ “, $x);
print_r($y);
Array ( [0] => Hello [1] => World!)
To concatenate, or combine, two strings you can use the______operator:
.
$x = “Hello”;
$y = “World”;
$z = $x . $y;
echo $z;
HelloWorld
Slicing string has _______ function.
substr() function.
Start the slice at index 6 and end the slice 5 positions later:
$x = “Hello World!”;
echo substr($x, 6, 5);
World
To insert characters that are illegal in a string, use an ________
escape character slash sign “
$x = “We are the so-called Slash sign”Vikings Slash sign” from the north.”
' _____Quote
" _____ Quote
$ ______
\n ____ Line
Single
Double
PHP variables ($ sign)
New
There are three main numeric types in PHP:
______, _______, ________
Integer, Float, Number Strings
In addition, PHP has two more data types used for numbers:
______
NaN
Infinity
NaN stands for ______
Not a Number.
The _____ function returns the absolute (positive) value of a number:
abs() echo(abs(-6.7)); = 6.7
The ____ function returns the square root of a number:
sqrt()
The _____ function rounds a floating-point number to its nearest integer:
round()
echo(round(0.60));
1
The _____ function generates a random number:
if you want a random integer between 10 and 100 (inclusive), use ________
rand()
echo(rand(10, 100));
echo(rand());
321343433 - 9 numbers