Basics Flashcards
What is PHP?
It is an open-source general-purpose scripting language.
it’s server-side.
Best suited for web development.
It’s an interpreted language.
Why you should learn PHP?
- Multi-purpose: good for simple and complex websites.
- CRM portals
- e-commerce systems
- Rest Api
- image/audio processing
- works with almost all data bases
PHP CMS?
wordpress, Magento, Drupal, OpenCart
For what is not great php?
For building real time apps(better Nodejs)
For AI and ML (better Python)
How do you comment in PHP?
// single line
# single line
/* multi line */
Do variables have types in PHP?
No, PHP is loosely typed.
How do you declare a variable?
with $
$my_name=’victoria’
What types are there in PHP?
- Strings
- Integer
- Float/Double
- Boolean
- Null
- Array
- Object
- Resource
How do you print a variable?
With echo
echo $variable
How do you concatenate in php?
with .
echo $name.’ ‘.$lastname
What happens if you try to print a boolean?
It converts it to a string : 1 for true and empty for false.
What happens if you try to print null?
It prints an empty string
How do you see the type of a variable?
with gettype($name);
How do I print a variable to see its type, length and value?
with var_dump()
var_dump($name) => string(4)”vica”
puedo pasarle más de una variable
Which ones are the variable type checking functions to see if a variable is a boolean, or a string, etc?
is_string($my_var)
is_int($my_var) / is_integer($my_var)
is_float($my_var) / is_double($my_var)
is_numeric($my_var)
is_bool($my_var)