Skip to the content ForoHackers
Log inJoin

PHP: start here

PHP
#3073 · · Quote · Report

PHP is a server-side scripting language built for the web: a script runs per request, reads input, talks to a database and returns HTML or data. It powers a very large share of existing sites and content management systems. Modern PHP is a typed, object-oriented language with a mature package ecosystem, quite unlike its early reputation.

Key concepts

  • Request lifecycle: each request starts a fresh script, with superglobals holding input and no state carried over by default.
  • Dynamic typing with type declarations: values convert freely, but declared types make code safer.
  • Classes, interfaces and traits: the object model of current PHP, with namespaces and autoloading.
  • Arrays: one flexible structure serves as list and dictionary.
  • Database access: prepared statements through a database abstraction layer.
  • Composer and frameworks: packages and frameworks provide routing, templating and structure.

Vocabulary

  • Superglobal: built-in variables such as the request data and the session.
  • Session: server-side state tied to a visitor by a cookie.
  • Autoloading: classes load when first used, from a naming convention.
  • Template: a file mixing markup with small bits of code to render output.

What to study, in order

  1. Basic syntax, arrays and functions, running scripts from the command line.
  2. Handle a form: read input, validate it, escape output, and store it with prepared statements.
  3. Classes, namespaces and Composer; split code into reusable pieces.
  4. Sessions, authentication and the common security pitfalls such as injection and cross-site scripting.
  5. A framework's routing, templates and testing.
  6. Deploy to a server and read its error logs.

Related tags

#backend #web-security #sql #web-frameworks

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply