Functions & PHP Flashcards
PHP meaning
Hypertext Preprocessor
PHP type of programming language
- open-source
- interpreted language
- general-purpose scripting language
- widely used in webdev
what is a php file?
can contain text, html tags, and scripts
- returned to the browser as plain html
php syntax
<?php
?>
outputting in php
echo
print
echo vs print
echo has no return value but can take multiple parameters
print has a return value of 1 making it usable for expressions
where does the php interpreter execute code?
server
declaring variables in php
- starts with $ symbol
- must START w/ letter or underscore(_)
- can only contain alpha-numeric characters and underscores
concatenating operator in php
dot (.)
( . ) ( . )
“hello”. “ “ .”world”;
function that returns length of string
strlen()
function that finds the position of the first occurrence of a string inside another string
strpos()
creating a newline in php
“<br></br>”
“\n”
getting date in php
d - Represents the day of the month (01 to 31)
m - Represents a month (01 to 12)
Y - Represents a year (in four digits)
l (lowercase ‘L’) - Represents the day of the week
echo “Today is “ . date(“Y/m/d”)
Output:
Today is 2020/11/03
parameters that are transferred to the function when it is requested.
actual parameter
a parameter that you specify when you determine the subroutine or function.
formal parameter or dummy parameter