Basics Flashcards

1
Q

What is PHP?

A

It is an open-source general-purpose scripting language.
it’s server-side.
Best suited for web development.
It’s an interpreted language.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why you should learn PHP?

A
  1. Multi-purpose: good for simple and complex websites.
  2. CRM portals
  3. e-commerce systems
  4. Rest Api
  5. image/audio processing
  6. works with almost all data bases
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

PHP CMS?

A

wordpress, Magento, Drupal, OpenCart

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

For what is not great php?

A

For building real time apps(better Nodejs)
For AI and ML (better Python)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you comment in PHP?

A

// single line
# single line
/* multi line */

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Do variables have types in PHP?

A

No, PHP is loosely typed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you declare a variable?

A

with $

$my_name=’victoria’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What types are there in PHP?

A
  1. Strings
  2. Integer
  3. Float/Double
  4. Boolean
  5. Null
  6. Array
  7. Object
  8. Resource
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you print a variable?

A

With echo

echo $variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you concatenate in php?

A

with .

echo $name.’ ‘.$lastname

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What happens if you try to print a boolean?

A

It converts it to a string : 1 for true and empty for false.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What happens if you try to print null?

A

It prints an empty string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you see the type of a variable?

A

with gettype($name);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do I print a variable to see its type, length and value?

A

with var_dump()

var_dump($name) => string(4)”vica”

puedo pasarle más de una variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which ones are the variable type checking functions to see if a variable is a boolean, or a string, etc?

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you check if a variable exists?

A

With isset()

isset($name)

esto devuelve un boolean

17
Q

How do you create a constant?

A

with define()

define(‘PI’,3.14)

Se pone primero el nombre, y después el valor.