SlideShare a Scribd company logo
1 of 4
Download to read offline
Server-Side Magazine_         PHP 5 Online Cheat Sheet v1.3 (updated November 13th, 2008)


     Type       Boolean Integer String Array Object/Class         String      functions conversion      Array       functions conversion

     Class      definition member declaration member visibility          Date/Time       functions formats      Predefined Variables       $_SERVER $_FILES




     Type: Boolean

         Values (case insensitive): TRUE, FALSE, true, false
         Casts: (bool), (boolean)
         The value -1 is considered TRUE, like any other non-zero (whether negative or positive) number!



     Type: Integer

         Casts: (int), (integer)
         If PHP encounters a number beyond the bounds of the integer type, it will be interpreted as a float instead.



     Type: String

         When a string is specified in double quotes (") the variables are parsed within it.
         Converting to string: with cast (string) or strval()
         String Functions:
             array explode( string $delimiter , string $string , [ int $limit ] ) - Returns an array of strings, each of which is a substring of string formed by
             splitting it on boundaries formed by the string delimiter
             string implode( string $glue , array $pieces ) - Join array elements with a glue string
             string htmlentities( string $string , [ int $quote_style , [ string $charset ,[ bool $double_encode ]]] ) - Convert all applicable characters to
             HTML entities
             string html_entity_decode( string $string , [ int $quote_style , [ string $charset ]] ) - Convert all HTML entities to their applicable characters
             int strlen( string $string ) - Get string length
             string strstr( string $haystack , mixed $needle , [ bool $before_needle ] ) - Find first occurrence of a string
             int strpos( string $haystack , mixed $needle , [ int $offset ] ) - Returns the numeric position of the first occurrence of needle in the haystack
             string
             string substr( string $string , int $start , [ int $length ] ) - Return part of a string



     Type: Array

         An array can be created by the array() language construct.
         The unset() function allows removing keys from an array.
         Converting to array:(array)$scalarValue or array($scalarValue)
         Array Functions:
             array array_diff( array $array1 , array $array2 , [ array $ ... ] ) - Compares array1 against array2 and returns the difference
             array array_keys( array $input , [ mixed $search_value ,[ bool $strict ]] ) - Return all the keys of an array
             array array_map( callback $callback , array $arr1 , [ array $... ] ) - Applies the callback to the elements of the given arrays
             bool array_walk( array &$array , callback $funcname ,[ mixed $userdata ] ) - Apply a user function to every member of an array
             array array_merge( array $array1 ,[ array $array2 , [ array $... ]] ) - Merge one or more arrays
             mixed array_pop( array &$array ) - Pop the element off the end of array
             int array_push( array &$array , mixed $var ,[ mixed $... ] ) - Push one or more elements onto the end of array
             mixed array_shift( array &$array ) - Shift an element off the beginning of array
             mixed array_unshift( array &$array , mixed $var , [ mixed $... ] ) - Prepend one or more elements to the beginning of an array
             array array_slice( array $array , int $offset ,[ int $length ,[ bool $preserve_keys ]] ) - Returns the sequence of elements from the array array
             as specified by the offset and length parameters
             array array_splice( array &$input , int $offset ,[ int $length ,[ mixed $replacement ]] ) - Removes the elements designated by offset and
             length from the input array, and replaces them with the elements of the replacement array, if supplied
             array in_array( mixed $needle , array $haystack ,[ bool $strict ] ) - Checks if a value exists in an array, searches haystack for needle



     Type: Object/Class

         To instatiate a class use the new statement.
         If a value of any other type is converted to an object, a new instance of the stdClass built-in class is created.
http://www.serversidemagazine.com/cheat-sheets/PHP5/keyword.
         Setting constants inside of class with const                                                                                                               Page 1 / 4
         Class definition:
To instatiate a class use the new statement.
         If a value of any other type is converted to an object, a new instance of the stdClass built-in class is created.
         Setting constants inside of class with const keyword.
         Class definition:
             general

                      1 class SampleClass {     
                      2 }

             abstract - It is not allowed to create an instance of a class that has been defined as abstract

                     1 abstract class SampleClass {    
                     2 }

             final - Prevents the class to be extended

                      1 final class SampleClass {
                      2 }

         Class members declaration:
             static - Declaring class members or methods as static makes them accessible without needing an instantiation of the class

                 1   class SampleClass {
                 2           
                 3           public static $class_propery = "foo";
                 4           
                 5           public static class_method() {
                 6                   //code here
                 7           }
                 8   }

             final - Prevents child classes from overriding a method

                 1    class SampleClass {
                 2     
                 3            final public class_method() {
                 4                    //code here
                 5            }
                 6    }

         Class members visibility:
             public - Public declared items can be accessed everywhere

                 1    class SampleClass {
                 2     
                 3            public $class_propery = "foo";
                 4     
                 5            public class_method() {
                 6                    //code here
                 7            }
                 8    }

             private - Private limits visibility only to the class that defines the item

                 1    class SampleClass {
                 2     
                 3            private $class_propery = "foo";
                 4     
                 5            private class_method() {
                 6                    //code here
                 7            }
                 8    }

             protected - Protected limits access to inherited and parent classes (and to the class that defines the item)

                 1    class SampleClass {
                 2     
                 3            protected $class_propery = "foo";
                 4     
                 5            protected class_method() {
                 6                    //code here
                 7            }
                 8    }




      Date/Time

         Functions:
             string date( string $format , [ int $timestamp ] ) - Returns a string formatted according to the given format string using the given integer
             timestamp or the current time if no timestamp is given
             void date_add( DateTime $object , DateInterval $interval ) - Adds an amount of days, months, years, hours, minutes and seconds to a DateTime
             object
http://www.serversidemagazine.com/cheat-sheets/PHP5/                                                                                                         Page 2 / 4
             int mktime( [ int $hour ,[ int $minute ,[ int $second ,[ int $month ,[ int $day ,[ int $year ,[ int $is_dst ]]]]]]] ) - Returns the Unix timestamp
             corresponding to the arguments given
void date_add( DateTime $object , DateInterval $interval ) - Adds an amount of days, months, years, hours, minutes and seconds to a DateTime
             object
             int mktime( [ int $hour ,[ int $minute ,[ int $second ,[ int $month ,[ int $day ,[ int $year ,[ int $is_dst ]]]]]]] ) - Returns the Unix timestamp
             corresponding to the arguments given
             int strtotime( string $time ,[ int $now ] ) - The function expects to be given a string containing a US English date format and will try to parse that
             format into a Unix timestamp
             int time() - Return current Unix timestamp
         Date/Time Formats:
             Day
                   d - 01 - 31
                   j - 1 - 31
                   D - Mon - Sun
                   l - Monday - Sunday
             Month
                   M - Jan - Dec
                   F - January - December
                   m - 01 - 12
                   n - 1 - 12
             Year
                   Y - 2003, 2008
                   y - 03, 08
             Time
                   a - am, pm
                   A - AM, PM
                   g - 12 hours - 1 - 12
                   h - 12 hours - 00 - 12
                   H - 24 hours - 00 - 23
                   G - 24 hours - 0 - 23
                   i - minutes - 00 - 59
                   s - seconds - 00 - 59



      Predefined Variables

         $_SERVER:
             The values in the array are provided by the server, there's no guarantee that all the values will be available on your
             configuration. In this list you can find the most used values only.
              
             PHP_SELF - the filename of the currently executing script, relative to the document root
             SERVER_ADDR - the IP address of the server
             SERVER_NAME - the name of the server
             REQUEST_METHOD - which request method was used to access the page: GET, HEAD, POST, PUT
             QUERY_STRING - the query string, if any, via which the page was accessed
             DOCUMENT_ROOT - the document root directory under which the current script is executing
             HTTP_REFERER - the address of the page (if any) which referred the user agent to the current page
             REMOTE_ADDR - the IP address from which the user is viewing the current page
             SCRIPT_FILENAME - the absolute pathname of the currently executing script
             REQUEST_URI - The URI which was given in order to access this page; e.g. /index.html
         $_FILES:
             $_FILES['userfile']['name'] - the original name of the file on the client machine
             $_FILES['userfile']['type'] - the mime type of the file, if the browser provided this information
             $_FILES['userfile']['size'] - the size, in bytes, of the uploaded file
             $_FILES['userfile']['tmp_name'] - the temporary filename of the file in which the uploaded file was stored on the server
             $_FILES['userfile']['error'] - The error code associated with this file upload
                   Error codes:
                   UPLOAD_ERR_OK or value 1 - no error
                   UPLOAD_ERR_INI_SIZE or value 2 - the uploaded file exceeds the upload_max_filesize directive in php.ini
                   UPLOAD_ERR_PARTIAL or value 3 - the uploaded file was only partially uploaded
                   UPLOAD_ERR_NO_FILE or value 4 - no file was uploaded
                   UPLOAD_ERR_NO_TMP_DIR or value 5 - missing temporary folder
                   UPLOAD_ERR_CANT_WRITE or value 7 - failed to write file to disk
                   UPLOAD_ERR_EXTENSION or value 8 - file upload stopped by extension
http://www.serversidemagazine.com/cheat-sheets/PHP5/                                                                                                            Page 3 / 4
UPLOAD_ERR_EXTENSION or value 8 - file upload stopped by extension




http://www.serversidemagazine.com/cheat-sheets/PHP5/                                  Page 4 / 4

More Related Content

What's hot

Object Orientation vs Functional Programming in Python
Object Orientation vs Functional Programming in PythonObject Orientation vs Functional Programming in Python
Object Orientation vs Functional Programming in PythonTendayi Mawushe
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Jonas Bonér
 
FFW Gabrovo PMG - PHP OOP Part 3
FFW Gabrovo PMG - PHP OOP Part 3FFW Gabrovo PMG - PHP OOP Part 3
FFW Gabrovo PMG - PHP OOP Part 3Toni Kolev
 
Object Oriented Programming with PHP 5 - More OOP
Object Oriented Programming with PHP 5 - More OOPObject Oriented Programming with PHP 5 - More OOP
Object Oriented Programming with PHP 5 - More OOPWildan Maulana
 
Introduction to class in java
Introduction to class in javaIntroduction to class in java
Introduction to class in javakamal kotecha
 
Doctrator Symfony Live 2011 San Francisco
Doctrator Symfony Live 2011 San FranciscoDoctrator Symfony Live 2011 San Francisco
Doctrator Symfony Live 2011 San Franciscopablodip
 
Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Jesper Kamstrup Linnet
 
Building a Pluggable Plugin
Building a Pluggable PluginBuilding a Pluggable Plugin
Building a Pluggable PluginBrandon Dove
 
Object Oriented Programming in PHP
Object Oriented Programming in PHPObject Oriented Programming in PHP
Object Oriented Programming in PHPLorna Mitchell
 
Python Puzzlers - 2016 Edition
Python Puzzlers - 2016 EditionPython Puzzlers - 2016 Edition
Python Puzzlers - 2016 EditionNandan Sawant
 
Lecture 4_Java Method-constructor_imp_keywords
Lecture   4_Java Method-constructor_imp_keywordsLecture   4_Java Method-constructor_imp_keywords
Lecture 4_Java Method-constructor_imp_keywordsmanish kumar
 
Programming in Java: Combining Objects
Programming in Java: Combining ObjectsProgramming in Java: Combining Objects
Programming in Java: Combining ObjectsMartin Chapman
 
Sql server difference faqs- 9
Sql server difference faqs- 9Sql server difference faqs- 9
Sql server difference faqs- 9Umar Ali
 

What's hot (20)

Spsl v unit - final
Spsl v unit - finalSpsl v unit - final
Spsl v unit - final
 
Object Orientation vs Functional Programming in Python
Object Orientation vs Functional Programming in PythonObject Orientation vs Functional Programming in Python
Object Orientation vs Functional Programming in Python
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)
 
FFW Gabrovo PMG - PHP OOP Part 3
FFW Gabrovo PMG - PHP OOP Part 3FFW Gabrovo PMG - PHP OOP Part 3
FFW Gabrovo PMG - PHP OOP Part 3
 
Object Oriented Programming with PHP 5 - More OOP
Object Oriented Programming with PHP 5 - More OOPObject Oriented Programming with PHP 5 - More OOP
Object Oriented Programming with PHP 5 - More OOP
 
Oop concepts in python
Oop concepts in pythonOop concepts in python
Oop concepts in python
 
Introduction to class in java
Introduction to class in javaIntroduction to class in java
Introduction to class in java
 
Doctrator Symfony Live 2011 San Francisco
Doctrator Symfony Live 2011 San FranciscoDoctrator Symfony Live 2011 San Francisco
Doctrator Symfony Live 2011 San Francisco
 
Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?
 
Java misc1
Java misc1Java misc1
Java misc1
 
Building a Pluggable Plugin
Building a Pluggable PluginBuilding a Pluggable Plugin
Building a Pluggable Plugin
 
Object Oriented Programming in PHP
Object Oriented Programming in PHPObject Oriented Programming in PHP
Object Oriented Programming in PHP
 
Scala - en bedre Java?
Scala - en bedre Java?Scala - en bedre Java?
Scala - en bedre Java?
 
Python Puzzlers - 2016 Edition
Python Puzzlers - 2016 EditionPython Puzzlers - 2016 Edition
Python Puzzlers - 2016 Edition
 
Lecture 4_Java Method-constructor_imp_keywords
Lecture   4_Java Method-constructor_imp_keywordsLecture   4_Java Method-constructor_imp_keywords
Lecture 4_Java Method-constructor_imp_keywords
 
Programming in Java: Combining Objects
Programming in Java: Combining ObjectsProgramming in Java: Combining Objects
Programming in Java: Combining Objects
 
10 classes
10 classes10 classes
10 classes
 
Sql server difference faqs- 9
Sql server difference faqs- 9Sql server difference faqs- 9
Sql server difference faqs- 9
 
Only oop
Only oopOnly oop
Only oop
 
Object oriented concepts
Object oriented conceptsObject oriented concepts
Object oriented concepts
 

Viewers also liked

สังคมศึกษาศาสนาและวัฒนธรรม ม.1 เสียดินแดน
สังคมศึกษาศาสนาและวัฒนธรรม ม.1 เสียดินแดนสังคมศึกษาศาสนาและวัฒนธรรม ม.1 เสียดินแดน
สังคมศึกษาศาสนาและวัฒนธรรม ม.1 เสียดินแดนton0860796891
 
perangkat keras untuk mengakses internet
perangkat keras untuk mengakses internetperangkat keras untuk mengakses internet
perangkat keras untuk mengakses internetRiriet MithaRockers
 
Git334 Week 1 Lecture
Git334 Week 1 LectureGit334 Week 1 Lecture
Git334 Week 1 Lecturechadwestover
 
Öncüoğlu
ÖncüoğluÖncüoğlu
ÖncüoğluArkiPARC
 
53669836 brake-test-on-a-d
53669836 brake-test-on-a-d53669836 brake-test-on-a-d
53669836 brake-test-on-a-dthicman
 
ISAAC 2012 Zangari & Paiva Preconference Workshop Handout
ISAAC 2012 Zangari & Paiva Preconference Workshop Handout ISAAC 2012 Zangari & Paiva Preconference Workshop Handout
ISAAC 2012 Zangari & Paiva Preconference Workshop Handout Carole Zangari
 

Viewers also liked (11)

Unit 4
Unit 4Unit 4
Unit 4
 
Compact Cars
Compact CarsCompact Cars
Compact Cars
 
สังคมศึกษาศาสนาและวัฒนธรรม ม.1 เสียดินแดน
สังคมศึกษาศาสนาและวัฒนธรรม ม.1 เสียดินแดนสังคมศึกษาศาสนาและวัฒนธรรม ม.1 เสียดินแดน
สังคมศึกษาศาสนาและวัฒนธรรม ม.1 เสียดินแดน
 
Flexible facility success
Flexible facility successFlexible facility success
Flexible facility success
 
perangkat keras untuk mengakses internet
perangkat keras untuk mengakses internetperangkat keras untuk mengakses internet
perangkat keras untuk mengakses internet
 
Fenis
FenisFenis
Fenis
 
Cem Avcı
Cem AvcıCem Avcı
Cem Avcı
 
Git334 Week 1 Lecture
Git334 Week 1 LectureGit334 Week 1 Lecture
Git334 Week 1 Lecture
 
Öncüoğlu
ÖncüoğluÖncüoğlu
Öncüoğlu
 
53669836 brake-test-on-a-d
53669836 brake-test-on-a-d53669836 brake-test-on-a-d
53669836 brake-test-on-a-d
 
ISAAC 2012 Zangari & Paiva Preconference Workshop Handout
ISAAC 2012 Zangari & Paiva Preconference Workshop Handout ISAAC 2012 Zangari & Paiva Preconference Workshop Handout
ISAAC 2012 Zangari & Paiva Preconference Workshop Handout
 

Similar to 0php 5-online-cheat-sheet-v1-3

Php object orientation and classes
Php object orientation and classesPhp object orientation and classes
Php object orientation and classesKumar
 
encapsulation, inheritance, overriding, overloading
encapsulation, inheritance, overriding, overloadingencapsulation, inheritance, overriding, overloading
encapsulation, inheritance, overriding, overloadingShivam Singhal
 
php_final_sy_semIV_notes_vision.pdf
php_final_sy_semIV_notes_vision.pdfphp_final_sy_semIV_notes_vision.pdf
php_final_sy_semIV_notes_vision.pdfakankshasorate1
 
php_final_sy_semIV_notes_vision (3).pdf
php_final_sy_semIV_notes_vision (3).pdfphp_final_sy_semIV_notes_vision (3).pdf
php_final_sy_semIV_notes_vision (3).pdfbhagyashri686896
 
php_final_sy_semIV_notes_vision.pdf
php_final_sy_semIV_notes_vision.pdfphp_final_sy_semIV_notes_vision.pdf
php_final_sy_semIV_notes_vision.pdfHarshuPawar4
 
php_final_sy_semIV_notes_vision.pdf
php_final_sy_semIV_notes_vision.pdfphp_final_sy_semIV_notes_vision.pdf
php_final_sy_semIV_notes_vision.pdfsannykhopade
 
Advanced php
Advanced phpAdvanced php
Advanced phphamfu
 
ハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使うハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使うbpstudy
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#Doncho Minkov
 
PhpUnit - The most unknown Parts
PhpUnit - The most unknown PartsPhpUnit - The most unknown Parts
PhpUnit - The most unknown PartsBastian Feder
 
Taxonomy of Scala
Taxonomy of ScalaTaxonomy of Scala
Taxonomy of Scalashinolajla
 
Lecture 17 - PHP-Object-Orientation.pptx
Lecture 17 - PHP-Object-Orientation.pptxLecture 17 - PHP-Object-Orientation.pptx
Lecture 17 - PHP-Object-Orientation.pptxDavidLazar17
 
Generic Programming
Generic ProgrammingGeneric Programming
Generic ProgrammingPingLun Liao
 

Similar to 0php 5-online-cheat-sheet-v1-3 (20)

Php object orientation and classes
Php object orientation and classesPhp object orientation and classes
Php object orientation and classes
 
encapsulation, inheritance, overriding, overloading
encapsulation, inheritance, overriding, overloadingencapsulation, inheritance, overriding, overloading
encapsulation, inheritance, overriding, overloading
 
Unit3 part1-class
Unit3 part1-classUnit3 part1-class
Unit3 part1-class
 
oops-1
oops-1oops-1
oops-1
 
Unit i
Unit iUnit i
Unit i
 
php_final_sy_semIV_notes_vision.pdf
php_final_sy_semIV_notes_vision.pdfphp_final_sy_semIV_notes_vision.pdf
php_final_sy_semIV_notes_vision.pdf
 
php_final_sy_semIV_notes_vision (3).pdf
php_final_sy_semIV_notes_vision (3).pdfphp_final_sy_semIV_notes_vision (3).pdf
php_final_sy_semIV_notes_vision (3).pdf
 
php_final_sy_semIV_notes_vision.pdf
php_final_sy_semIV_notes_vision.pdfphp_final_sy_semIV_notes_vision.pdf
php_final_sy_semIV_notes_vision.pdf
 
php_final_sy_semIV_notes_vision.pdf
php_final_sy_semIV_notes_vision.pdfphp_final_sy_semIV_notes_vision.pdf
php_final_sy_semIV_notes_vision.pdf
 
Advanced php
Advanced phpAdvanced php
Advanced php
 
Scala cheatsheet
Scala cheatsheetScala cheatsheet
Scala cheatsheet
 
Recursion Lecture in Java
Recursion Lecture in JavaRecursion Lecture in Java
Recursion Lecture in Java
 
ハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使うハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使う
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
 
PhpUnit - The most unknown Parts
PhpUnit - The most unknown PartsPhpUnit - The most unknown Parts
PhpUnit - The most unknown Parts
 
Taxonomy of Scala
Taxonomy of ScalaTaxonomy of Scala
Taxonomy of Scala
 
Scala Paradigms
Scala ParadigmsScala Paradigms
Scala Paradigms
 
Lecture 17 - PHP-Object-Orientation.pptx
Lecture 17 - PHP-Object-Orientation.pptxLecture 17 - PHP-Object-Orientation.pptx
Lecture 17 - PHP-Object-Orientation.pptx
 
Generic Programming
Generic ProgrammingGeneric Programming
Generic Programming
 
Java Unit 2(Part 1)
Java Unit 2(Part 1)Java Unit 2(Part 1)
Java Unit 2(Part 1)
 

Recently uploaded

How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 

Recently uploaded (20)

How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 

0php 5-online-cheat-sheet-v1-3

  • 1. Server-Side Magazine_         PHP 5 Online Cheat Sheet v1.3 (updated November 13th, 2008) Type Boolean Integer String Array Object/Class String functions conversion Array functions conversion Class definition member declaration member visibility Date/Time functions formats Predefined Variables $_SERVER $_FILES Type: Boolean Values (case insensitive): TRUE, FALSE, true, false Casts: (bool), (boolean) The value -1 is considered TRUE, like any other non-zero (whether negative or positive) number! Type: Integer Casts: (int), (integer) If PHP encounters a number beyond the bounds of the integer type, it will be interpreted as a float instead. Type: String When a string is specified in double quotes (") the variables are parsed within it. Converting to string: with cast (string) or strval() String Functions: array explode( string $delimiter , string $string , [ int $limit ] ) - Returns an array of strings, each of which is a substring of string formed by splitting it on boundaries formed by the string delimiter string implode( string $glue , array $pieces ) - Join array elements with a glue string string htmlentities( string $string , [ int $quote_style , [ string $charset ,[ bool $double_encode ]]] ) - Convert all applicable characters to HTML entities string html_entity_decode( string $string , [ int $quote_style , [ string $charset ]] ) - Convert all HTML entities to their applicable characters int strlen( string $string ) - Get string length string strstr( string $haystack , mixed $needle , [ bool $before_needle ] ) - Find first occurrence of a string int strpos( string $haystack , mixed $needle , [ int $offset ] ) - Returns the numeric position of the first occurrence of needle in the haystack string string substr( string $string , int $start , [ int $length ] ) - Return part of a string Type: Array An array can be created by the array() language construct. The unset() function allows removing keys from an array. Converting to array:(array)$scalarValue or array($scalarValue) Array Functions: array array_diff( array $array1 , array $array2 , [ array $ ... ] ) - Compares array1 against array2 and returns the difference array array_keys( array $input , [ mixed $search_value ,[ bool $strict ]] ) - Return all the keys of an array array array_map( callback $callback , array $arr1 , [ array $... ] ) - Applies the callback to the elements of the given arrays bool array_walk( array &$array , callback $funcname ,[ mixed $userdata ] ) - Apply a user function to every member of an array array array_merge( array $array1 ,[ array $array2 , [ array $... ]] ) - Merge one or more arrays mixed array_pop( array &$array ) - Pop the element off the end of array int array_push( array &$array , mixed $var ,[ mixed $... ] ) - Push one or more elements onto the end of array mixed array_shift( array &$array ) - Shift an element off the beginning of array mixed array_unshift( array &$array , mixed $var , [ mixed $... ] ) - Prepend one or more elements to the beginning of an array array array_slice( array $array , int $offset ,[ int $length ,[ bool $preserve_keys ]] ) - Returns the sequence of elements from the array array as specified by the offset and length parameters array array_splice( array &$input , int $offset ,[ int $length ,[ mixed $replacement ]] ) - Removes the elements designated by offset and length from the input array, and replaces them with the elements of the replacement array, if supplied array in_array( mixed $needle , array $haystack ,[ bool $strict ] ) - Checks if a value exists in an array, searches haystack for needle Type: Object/Class To instatiate a class use the new statement. If a value of any other type is converted to an object, a new instance of the stdClass built-in class is created. http://www.serversidemagazine.com/cheat-sheets/PHP5/keyword. Setting constants inside of class with const Page 1 / 4 Class definition:
  • 2. To instatiate a class use the new statement. If a value of any other type is converted to an object, a new instance of the stdClass built-in class is created. Setting constants inside of class with const keyword. Class definition: general 1 class SampleClass {      2 } abstract - It is not allowed to create an instance of a class that has been defined as abstract 1 abstract class SampleClass {     2 } final - Prevents the class to be extended 1 final class SampleClass { 2 } Class members declaration: static - Declaring class members or methods as static makes them accessible without needing an instantiation of the class 1 class SampleClass { 2          3         public static $class_propery = "foo"; 4          5         public static class_method() { 6                 //code here 7         } 8 } final - Prevents child classes from overriding a method 1 class SampleClass { 2   3         final public class_method() { 4                 //code here 5         } 6 } Class members visibility: public - Public declared items can be accessed everywhere 1 class SampleClass { 2   3         public $class_propery = "foo"; 4   5         public class_method() { 6                 //code here 7         } 8 } private - Private limits visibility only to the class that defines the item 1 class SampleClass { 2   3         private $class_propery = "foo"; 4   5         private class_method() { 6                 //code here 7         } 8 } protected - Protected limits access to inherited and parent classes (and to the class that defines the item) 1 class SampleClass { 2   3         protected $class_propery = "foo"; 4   5         protected class_method() { 6                 //code here 7         } 8 } Date/Time Functions: string date( string $format , [ int $timestamp ] ) - Returns a string formatted according to the given format string using the given integer timestamp or the current time if no timestamp is given void date_add( DateTime $object , DateInterval $interval ) - Adds an amount of days, months, years, hours, minutes and seconds to a DateTime object http://www.serversidemagazine.com/cheat-sheets/PHP5/ Page 2 / 4 int mktime( [ int $hour ,[ int $minute ,[ int $second ,[ int $month ,[ int $day ,[ int $year ,[ int $is_dst ]]]]]]] ) - Returns the Unix timestamp corresponding to the arguments given
  • 3. void date_add( DateTime $object , DateInterval $interval ) - Adds an amount of days, months, years, hours, minutes and seconds to a DateTime object int mktime( [ int $hour ,[ int $minute ,[ int $second ,[ int $month ,[ int $day ,[ int $year ,[ int $is_dst ]]]]]]] ) - Returns the Unix timestamp corresponding to the arguments given int strtotime( string $time ,[ int $now ] ) - The function expects to be given a string containing a US English date format and will try to parse that format into a Unix timestamp int time() - Return current Unix timestamp Date/Time Formats: Day d - 01 - 31 j - 1 - 31 D - Mon - Sun l - Monday - Sunday Month M - Jan - Dec F - January - December m - 01 - 12 n - 1 - 12 Year Y - 2003, 2008 y - 03, 08 Time a - am, pm A - AM, PM g - 12 hours - 1 - 12 h - 12 hours - 00 - 12 H - 24 hours - 00 - 23 G - 24 hours - 0 - 23 i - minutes - 00 - 59 s - seconds - 00 - 59 Predefined Variables $_SERVER: The values in the array are provided by the server, there's no guarantee that all the values will be available on your configuration. In this list you can find the most used values only.   PHP_SELF - the filename of the currently executing script, relative to the document root SERVER_ADDR - the IP address of the server SERVER_NAME - the name of the server REQUEST_METHOD - which request method was used to access the page: GET, HEAD, POST, PUT QUERY_STRING - the query string, if any, via which the page was accessed DOCUMENT_ROOT - the document root directory under which the current script is executing HTTP_REFERER - the address of the page (if any) which referred the user agent to the current page REMOTE_ADDR - the IP address from which the user is viewing the current page SCRIPT_FILENAME - the absolute pathname of the currently executing script REQUEST_URI - The URI which was given in order to access this page; e.g. /index.html $_FILES: $_FILES['userfile']['name'] - the original name of the file on the client machine $_FILES['userfile']['type'] - the mime type of the file, if the browser provided this information $_FILES['userfile']['size'] - the size, in bytes, of the uploaded file $_FILES['userfile']['tmp_name'] - the temporary filename of the file in which the uploaded file was stored on the server $_FILES['userfile']['error'] - The error code associated with this file upload Error codes: UPLOAD_ERR_OK or value 1 - no error UPLOAD_ERR_INI_SIZE or value 2 - the uploaded file exceeds the upload_max_filesize directive in php.ini UPLOAD_ERR_PARTIAL or value 3 - the uploaded file was only partially uploaded UPLOAD_ERR_NO_FILE or value 4 - no file was uploaded UPLOAD_ERR_NO_TMP_DIR or value 5 - missing temporary folder UPLOAD_ERR_CANT_WRITE or value 7 - failed to write file to disk UPLOAD_ERR_EXTENSION or value 8 - file upload stopped by extension http://www.serversidemagazine.com/cheat-sheets/PHP5/ Page 3 / 4
  • 4. UPLOAD_ERR_EXTENSION or value 8 - file upload stopped by extension http://www.serversidemagazine.com/cheat-sheets/PHP5/ Page 4 / 4