Looks like no one added any tags here yet for you.
what is PHP
stands for “PHP: hypertext preprocessor”
an interpreted programming language that is used to build webpages
why is PHP preferred over alternative languages for web development *
it is popular?
open-source
embedded within HTML, making it easy to integrate dynamic content into web pages
how do you set variables in PHP
variable names start with a $ in PHP
followed by a word that describes the info held
equals sign in the assignment operator
scalar (primitive) data types in PHP
string - represents text
$name = ‘pinecone’ (fuck this cat bro)
int/float - two types of number data types
int - whole numbers
decimal - fractions, $number = 3.75
boolean (TRUE/FALSE)
NULL - represents nothing, not set
T/F, variables are updateable in php
true
compound data type (non-primitive) in PHP
arrays
how are php objects/arrays similar to JS?
both can be accessed by their index
associative access (essentially means that you can access both by property)
dynamic structure
how are php objects/arrays different to JS? *
syntax differs
different methods
iteration is different
How to work with classes and objects and do things like access object
properties/methods, etc
class Car
{
// properties
public $brand;
public $model;
// methods
public function start() {
return “The {$this → brand} {$this→model} is starting.”; }
}
// creating an object
$myCar = new Car(“toyota”, “camry”)';
// accessing an object
echo $myCar → brand; // outputs Toyota
how to work with indexed and associative arrays
how we access/handle data from different HTTP methods(ties into REST, what should a POST do?
some http methods include post, get, put, delete, patch
post should submit data to be processed by the server
what does MVC stand for
model, view, controller
separates an application into three main components built to handle specific development aspects of an application
what is model
interacts with database and perfroms data manipulation
what is view
represents the presentation layer - displaying user interface
usually HTML templates that may include embedded PHP code
what is controller
acts as an intermediary between the model and the view
receives user input, processes requests, and updates the model
what is REST
stands for “representational state transfer”
makes it easier for systems to communicate with each other
validation
making sure that the data coming in from the front end is correct
first step - escape any harmful characters
why do we need to escape data
escaping data will remove bad scripts
we don’t want hackers to send us malicious code
escaping data involves removing and replacing any characters that should not appear in a value
what are sessions
store information about a user and their preferences on the server
called sessions because they only store the data for the duration of a single visit to the site
how do sessions work
every page that uses sessions should call the session_start()
this automatically creates a session cookie for the browser
temporary, session cookies are deleted when the browser is closed
cookies
a website can tell a browser to store data about the user in a text file called a cookie
each time the browser requests another page from that site, the browser sends the data in the cookie back to the server
how do cookies work
php has a set_cookie() function to create a cookie
to access, $_COOKIE super global array
what is SQL
stands for “structured query language”
it is the standard language for database creation and manipulation
what is MySQL
a relational database program that uses SQL queries
what is a regional database
includes tables, rows, columns, fields, keys
what are select statements
select species the columns with the ‘select’ keyword
and the intended table with the ‘from’ keyword
what is the where clause
what are joins in SQL
‘join’ is a keyword that allows you to request data from more than one table
join are generally how we make use of relationships
join types - idk how important this is
what are relationships
established associations between two or more tables
based on common fields from more than one table, often involving primary and foreign keys
primary keys
the field that is used to uniquely identify each record in a table
cannot be NULL, must be unique, and there can be only one defined per table
foreign keys
a field (or fields) in one table that references the primary key in another table
PDOs
represent and manage the connection to the database
set up a connection and then run queries though it
via PDOs, PHP is going to take sql as input and return results from the database and store it in a variable
what are prepared statements
prepared statements help guard against SQL injection hacks
will automatically run escaping functions on the params about to be used
SQL injection
a hack when a hacker tries to run malicious SQL code in a database