File: index.php


Display: echo ‘… ‘;                                   

Print: print_r(…);

Comment: //, #, /*…*/

Break: echo ”

Concatenate: echo $x.$y; / echo ‘string’.$x; / echo “string $x”;

  • Operator

Arithmetic: +, -, *, /, %, **

Assignment: =, +=, -=, *=, /=, %=

Comparison: ==, ===, !=, <>, !==, >, <, >=, <=

Increment / Decrement: ++$x, $x++, –$x, $x—

Logical: and, or, xor, &&, ||, !

String: ., .=

Array: +, ==, ===, !=, <>, !==

  • Data Types: String, Integer, Float, Boolean, Array, Object, Null, Resource
  • Variable

Remove a variable: unset($x);

String: $var_name = ‘… ‘;

Integer: $var_name = 1;

Value: $y=x;

Access variable value: $y

  • Constant – global scope

define(“constantName, value, case-insensitive true)

Magic Constants

  • String Functions

strlen(“…”); – get the length of a string

str_word_count(“…”); – count the numbers of words in a string

strrev(“…”); – reverse a string

strpos(“…”); – search for the position of a text within a string

str_replace(wordToReplace“, “newWord“, “String); – replace text within a string

  • Variable Scope: Local, Global, Static

global $var_name – to access a global variable from within a function

static – to keep the variables after the function has been executed

  • Object

class Objectname { $this -> keyName = “…”; }

  • Function

Default Argument Value: function functionName($parameter = 1) { echo “…”; }

Date: date(“Y/m/d”), date(“l”)

Time: date_default_timezone_set(“America/New_York”); date(“h:i:sa”)

mktime(hour, minute, second, month, day, year);

strtotime(time, now); / strtotime(tomorrow); / strtotime(next Saturday); / strtotime(+3 Months);

  • Superglobals

$GLOBALS[ var_name ] – to access and update a global variable from within a function

$_SERVER[ element ] – holds info about headers, paths and script locations

$_REQUEST[ inputName ] – used to collect data after submitting an html form

$_POST[ inputName ]






• GET: $_GET
– used to request data from a resource, – requests show query strings and values in the URL
– requests can be bookmarked, cached and remain in your history
– requests are only for retrieving data
• POST: <form method=”post”>
– used to send data to a resource
– requests show query names and values only in the body of the request
– requests are not bookmarked, cached and will not remain in your history

PHP Form: tutorial

About bernadetteengleman

Hello, I am Bernadette from New York City. I moved here from Chicago in 2013. I am originally from the Philippines. I started studying web programming in 2015. I love it because I like making fun websites and web apps. The projects that I built so far are posted below. I like to cook and I love to travel. I also like to volunteer and I am a team leader with the non-profit organization, NYCares.
This entry was posted in php. Bookmark the permalink.

2 Responses to Basic

  1. Alex says:

    Excellent blog right here! Additionally your website so much up fast! What web host are you using? Can I am getting your affiliate hyperlink for your host? I wish my website loaded up as quickly as yours lol


  2. Dolly James says:

    I am now not sure the place you are getting your info, but great topic. I must spend some time studying much more or understanding more. Thank you for magnificent information I used to be searching for this information for my mission.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s