SlideShare a Scribd company logo
1 of 110
Download to read offline
DATA TYPES IN
PHP
MARK NIEBERGALL
https://joind.in/talk/6d7f9
ABOUT MARK NIEBERGALL
DATA TYPES IN PHP
• PHP since 2005
• Masters degree in MIS
• Senior Software Engineer
• Team Lead
• Drug screening project
• President of Utah PHP User Group (UPHPU)
• SSCP, CSSLP Certified and SME for (ISC)2
• PHP, databases, JavaScript
• Drones, fishing, skiing, father, husband
ABOUT MARK NIEBERGALL
DATA TYPES IN PHP
ABOUT MARK NIEBERGALL
DATA TYPES IN PHP
UPHPU
DATA TYPES IN PHP
• Third Thursday of each month at 7pm
• Venue is Vivint in Lehi (3401 Ashton Blvd)
• Variety of PHP related topics
• Mostly local speakers, occasional traveling speaker
• Networking with other developers, companies
• Professional development
• uphpu.org
DATA TYPES IN
PHP
OVERVIEW
DATA TYPES IN PHP
• Identify and define each type
• Proper usage
• Type juggling
• Data type traps
• Defensive coding
• Unit tests
CAN YOU NAME ALL
THE DATA TYPES?
IDENTIFY AND DEFINE
DATA TYPES IN PHP
• 8 data types
• 4 scalar
• 2 compound
• 2 special
IDENTIFY AND DEFINE
DATA TYPES IN PHP
• Scalar
• string
• integer
• float (double)
• boolean
• Compound
• array
• object
• Special
• null
• resource
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Scalar Compound Special
string array null
integer object resource
float
boolean
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Scalar Compound Special
‘Hello world’ [1, 2, 3] null
123 new X fopen
12.34
TRUE
STRING
IDENTIFY AND DEFINE
DATA TYPES IN PHP
String
• $var = ‘Hello world!’;
• Series of characters
• Up to 2GB
• Scalar type
• is_string
IDENTIFY AND DEFINE
DATA TYPES IN PHP
String
• $name = ‘Alice’;
• Single quote: $var = ‘Hello $name’;
• Output: Hello $name
IDENTIFY AND DEFINE
DATA TYPES IN PHP
String
• $name = ‘Alice’;
• Double quote: $var = “Hello $name”;
• Output: Hello Alice
IDENTIFY AND DEFINE
DATA TYPES IN PHP
String
• $name = ‘Alice’;
• Heredoc: $var = <<<EOD

Hello $name

EOD;
• Output: Hello Alice
IDENTIFY AND DEFINE
DATA TYPES IN PHP
String
• $name = ‘Alice’;
• Nowdoc: $var = <<<‘EOD’

Hello $name

EOD;
• Output: Hello $name
IDENTIFY AND DEFINE
DATA TYPES IN PHP
String
• $name = ‘Alice’;
• $var = ‘Hello ‘ . $name;
• $var = “Hello $name”;
• $var = “Hello {$name}”;
• $var = “Hello {$person[‘name’]}”;
• $var = “Hello {$person->name}”;
• Output: Hello Alice
IDENTIFY AND DEFINE
DATA TYPES IN PHP
String
• $escaped = ‘t’;
• Output: 't'
• $escaped = “t”;
• Output: ‘ ‘
IDENTIFY AND DEFINE
DATA TYPES IN PHP
INTEGER
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Integer
• $number = 16;
• Scalar type
• Positive or negative: -16 or 16
• is_int or is_integer
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Integer
• Decimal (base 10): 16
• Hexadecimal (base 16, leading 0x): 0x10
• Octal (base 8, leading 0): 020
• Binary (base 2, leading 0b): 0b10000
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Integer
• Max 2,147,483,647 on 32-bit system
• Max 9,223,372,036,854,775,807 on 64-bit system
• Becomes a float if too big
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Integer
• Automatically converted to float in math where result is not a
whole number
• 16 / 2 = integer 8
• 16 / 3 = float 5.3333333333333
• (int) ((0.1 + 0.7) * 10) = (int) 7
• Precision with floats
• Float to integer always rounded toward zero
FLOAT
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Float
• $var = 12.34;
• Scalar type
• Double
• Floating-point number
• Real numbers
• is_float, is_double, or is_real
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Float
• Uses IEEE 754 standard for calculations
• Arithmetic formats
• Interchange formats
• Rounding rules
• Operations
• Exception handling (overflow, divide by zero)
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Float
• $var = 12.34
• $var = 12.3e4
• $var = 12E-3
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Float
• Precision varies by platform
• Limited precision
• Uses base 2 under the hood
• Prone to accuracy problems
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Float
• (0.1 + 0.7) * 10 = 7.9999…
• floor((0.1 + 0.7) * 10) = 7
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Float
• Use libraries for float math like BC Math or gmp
• bcadd, bcmul
• gmp_add, gmp_mul
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Float
• BCMath Arbitrary Precision Mathematics
• bcxxx($leftOperand, $rightOperand [, $scale])
• bcscale($scale)
• bcadd($a, $b)
• bcmul($a, $b)
• bcdiv($a, $b)
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Float
• GNU Multiple Precision
• gmp_xxx($leftOperand, $rightOperand [, $rounding])
• GMP_ROUND_ZERO
• GMP_ROUND_PLUSINF
• GMP_ROUND_MINUSINF
• gmp_init($number)
• gmp_add($a, $b)
• gmp_mul($a, $b)
• gmp_div($a, $b, GMP_ROUND_ZERO)
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Float
• Keep precision in mind
• Use libraries for accuracy
BOOLEAN
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Boolean
• $var = true;
• Scalar type
• Boolean or Bool
• Only two possible values: true or false
• is_bool
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Boolean
• $var = true;
• 0 == false
• 1 == true
• 2 == true
• -1 == true
• 3.45 == true
• ‘abc’ == true
• ‘false’ == true
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Boolean
• true === true
• false === false
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Boolean
• Good to work with
• Simplify checks
ARRAY
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Array
• $var = [1, 2, 3];
• Compound type
• is_array
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Array
• $var = [1, 2, 3, 4.56];
• $var = [‘abc’, ‘xyz’];
• $var = [‘fruit’ => ‘apple’, ‘vegetable’ => ‘carrot’];
• $var = array(‘key’ => ‘value’);
• $var[‘key’] = ‘value’;
• $var[] = ‘value’;
• $var{123} = ‘value’;
• $var = explode(‘,’, $csv);
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Array
• Ordered map
• Keys and values
• Keys are integer or string
• Value can be of any data type
• If adding value to array then key = max numeric key + 1
where max numeric key is max that has existed since last re-
index
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Data Type Key Key Cast As
string ‘abc123' ‘abc123'
string ‘123’ 123
float 12.34 12
bool true 1
null null ‘'
array […] Illegal offset
object new X Illegal offset
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Array
• foreach ($array as $key => $value) { … }
• foreach ($array as &$value) { … }
• for ($i = 0; $i < count($array); $i++) { … }
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Array
• Many useful array functions
• ksort
• asort
• array_keys
• array_key_exists
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Array
• array_merge
• array_intersect
• array_column
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Array
• array_push
• array_pop
• array_shift
• array_unshift
• array_splice
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Array
• Use wisely
• Use available array functions
• Avoid overly nested arrays
• Watch key casting
OBJECT
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Object
• $var = new X;
• Compound type
• is_class
• instanceof
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Object
• $var = new X;
• $var = new X($value);
• $var->doSomething($parameter);
• $var::staticMethod();
• $var::SOME_CONSTANT;
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Object
• Constants
• Properties
• Methods
• Magic methods
• Visibility modifiers
• Final keyword
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Object



class RainbowTrout extends Fish implements MarineLife {

use Camouflage;
const SPECIES = ‘Rainbow Trout’;

protected $age;
public function swim() { … }
protected function breathe() { … }

public function eat(Food $food) { … }
private function ponder(Thought $thought) { … }
}
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Object
• Abstract
• Interface
• Trait
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Object
• Abstract
• Vertical inheritance via extend
• class Dog extends Canine
• Is X a Y?
• Code reusability
• Ensure functionality
• Only extend one class at a time
• Can have multiple levels
• Cannot be instantiated
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Object
• Abstract
• abstract Canine {

public function wagTail() { … }

abstract public function run();

}
• class Dog extends Canine {

public function run() { … }

}
• $dog = new Dog;

$dog->wagTail();

$dog->run();
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Object
• Interface
• Class implements an interface
• Define required method signatures
• Does not define content of methods
• Class defines the implementation
• What class needs to do, not how to do it
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Object
• Interface
• interface PlayFetch {

public function retrieveItem(Item $item);

}
• class Dog implements PlayFetch {

public function retrieveItem(Item $item) { … }

}
• class Child extends Human implements PlayFetch, TakeNap {

public function retrieveItem(Item $item) { … }

public function fallAsleep() { … }

}
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Object
• Trait
• Characteristic
• Attribute
• Reusable group functionality
• Horizontal inheritance
• Cannot be instantiated
• Can use multiple traits
• Vertical inheritance considerations
• Dependency injection considerations
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Object
• Trait
• trait Hair {

protected $color;

public function setHairColor($color) { … }

public function washHair($shampoo) { … }

}
• class Cat extends Feline { use Hair; }
• $cat = new Cat;

$cat->setHairColor(‘grey’);

$cat->washHair($shampoo);
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Object
• Type hinting
• Method signatures
• public function doSomething(X $x, array $y) { … }
• Doc blocks
• /** @var integer */
• Method return type hint as of PHP 7
• public function sum($a, $b): integer { … }
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Object
• Heavily used with PHP applications
• Advanced functionality
• Inheritance
• Code reuse
NULL
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Null
• $var;
• $var = null;
• Special type
• Represents no value
• is_null
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Null
• public function doNothing() {}
• $value = $object->doNothing();
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Null
• $value = null;
• Works: empty($value) === true
• Best: is_null($value) === true
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Null
• unset($value)
• $value becomes null
RESOURCE
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Resource
• Special type
• Reference to an external resource
• Database connection
• Open files
• Certificates
• Image canvas
• get_resource_type
• is_resource
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Resource
• $resource = new mysqli(…);
• $handle = fopen($fileName, ‘r’);
• $privateKey = openssl_pkey_new([…]);
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Resource
• Can be closed manually
• Automatically closed when no more references
• Memory freed by garbage collector
• Exception to the rule are persistent database connections
IDENTIFY AND DEFINE
DATA TYPES IN PHP
Resource
• Cannot cast to resource
DEFENSIVE
CODING
DEFENSIVE CODING
DATA TYPES IN PHP
Defensive Coding
• Hope for the best and prepare for the worst
• Type hinting
• Type checking
• Type casting
DEFENSIVE CODING
DATA TYPES IN PHP
DEFENSIVE CODING
DATA TYPES IN PHP
Type Hinting
• Use heavily
• Provides documentation
• Supports ‘Fail fast’
• Ensures data is of correct type or instance
• Makes code easier to read and understand by peers
DEFENSIVE CODING
DATA TYPES IN PHP
Type Hinting
• Method parameters
• protected function doSomething(int $a, float $b, bool $c,
array $d, X $x) { … }
• Method return
• private function doOther(SomeClass $someClass): someClass
{ … }
DEFENSIVE CODING
DATA TYPES IN PHP
Type Checking
• Use proper data type checks
• is_null instead of empty
• is_float instead of is_numeric
• === when possible
• instanceof checks
• count vs empty
DEFENSIVE CODING
DATA TYPES IN PHP
Comparison
Operators
Loose Strict
Operator == ===
Type Check No Yes
Type
Conversion
Yes No
DEFENSIVE CODING
DATA TYPES IN PHP
Type Casting
• Automatic
• Manual
DEFENSIVE CODING
DATA TYPES IN PHP
Type Casting
• Automatic
• PHP is a loosely typed language
• Variable data type can change
• Particularly with going to string or integer
• Unintentionally introduce defects
• ‘1’ + ‘2’ === 3
• 1 + ‘1 way’ === 2
DEFENSIVE CODING
DATA TYPES IN PHP
Type Casting
• Manual
• Cast variable as a specific type
• (int) false === 0
• (int) 12.34 === 12
• (int) ‘123abc’ === 123
DEFENSIVE CODING
DATA TYPES IN PHP
Type Casting
• Manual
• Cast variable as a specific type
• (string) false === ‘’
• (string) true === ‘1’
• (string) 12.34 === ’12.34’
DEFENSIVE CODING
DATA TYPES IN PHP
Type Casting
• Manual
• Cast variable as a specific type
• (bool) ‘false’ === true
• (boolean) 1 === true
DEFENSIVE CODING
DATA TYPES IN PHP
Type Casting
• Manual
• Cast variable as a specific type
• (float) ’12.34’ === 12.34
• (double) 12 === 12
• (real) ‘’ === 0
DEFENSIVE CODING
DATA TYPES IN PHP
Type Casting
• Manual
• Cast variable as a specific type
• (array) ‘scalar’ === [‘scalar’]
• (array) new Exception === [‘* message’ => ‘’, ‘Exception
string’ => ‘’, ‘* code’ => 0, ‘* file’ => ‘/path/to/file.php’, ‘*
line’ => 123, ‘Exception trace’ => […], ‘Exception previous’
=> null]
• Classname key for private
• Asterisk * for protected
DEFENSIVE CODING
DATA TYPES IN PHP
Type Casting
• Manual
• Cast variable as a specific type
• (object) [1, 2, 3] becomes stdClass{public 0 = 1; public 1 = 2;
public 3 = 2;}
• (object) ‘something’ becomes stdClass{public ‘scalar’ =
‘something’;}
• (object) null becomes stdClass{}
DEFENSIVE CODING
DATA TYPES IN PHP
Type Casting
• Manual
• Cast variable as a specific type
• (unset) ‘anything’ === null
• (unset) $value === null
• returns null
• $value retains existing value
UNIT TESTS
UNIT TESTS
DATA TYPES IN PHP
Unit Tests
• Automated way to test code
• Data type checks
• Value checks
• Code behaves as expected
UNIT TESTS
DATA TYPES IN PHP
Setup
• Via composer
• Add to composer.json:
• “require-dev”: {“phpunit/phpunit”: “5.4.*”}
• composer update
• Via download
• wget https://phar.phpunit.de/phpunit.phar

chmod +x phpunit.phar

sudo mv phpunit.phar /usr/local/bin/phpunit
UNIT TESTS
DATA TYPES IN PHP
Create Class With Tests
• Create /tests/ directory
• Files named *Test.php
• If using composer
• require_once __DIR__ . ‘/../vendor/autoload.php’;
• use PHPUnitFrameworkTestCase;

class FilenameTest extends TestCase { … }
UNIT TESTS
DATA TYPES IN PHP
Create Class With Tests
• Focus today is on data types
• Data providers to provide test data sets
UNIT TESTS
DATA TYPES IN PHP
Create Class With Tests
• assertEquals($expected, $actual [, $message])
• Value is equal
• No data type check
• ==
• assertSame($expected, $actual [, $message])
• Value is equal
• Data type is same
• ===
UNIT TESTS
DATA TYPES IN PHP
Create Class With Tests
• Use setUp to set class
• protected function setUp() {

parent::setup();

$this->intMath = new IntMath;

}
UNIT TESTS
DATA TYPES IN PHP
Create Class With Tests
• Use data providers to use test data sets
• /** @dataprovider intAdditionProvider */

public function testAddInts($a, $b, $expected) {

$this->assertSame($expected, $this->IntMath->add($a, $b));

}

public function intAdditionProvider() {

return [

[0, 0, 0],

[1, 2, 3],

[-1, 1, 0]

];

}
UNIT TESTS
DATA TYPES IN PHP
Create Class With Tests
• assertContains($needle, $haystack [, $message, $ignoreCase])
• Value (needle) exists in haystack
• Defaults to not ignore case
• assertContainsOnly($type, $haystack [, $isNativeType, $message])
• Is type the only data type in the haystack
UNIT TESTS
DATA TYPES IN PHP
Create Class With Tests
• assertFalse($condition [, $message])
• assertNotFalse($condition [, $message])
• assertTrue($condition [, $message])
• assertNotTrue($condition [, $message])
UNIT TESTS
DATA TYPES IN PHP
Create Class With Tests
• assertNull($variable [, $message])
• assertNotNull($variable [, $message])
UNIT TESTS
DATA TYPES IN PHP
Create Class With Tests
• assertInstanceOf($expected, $actual [, $message])
• assertContainsOnlyInstancesOf($classname, $haystack [,
$message])
• Instance checks in array or Traversable
UNIT TESTS
DATA TYPES IN PHP
Create Class With Tests
• assertLessThan
• assertLessThanOrEqual
• assertGreaterThan
• assertGreaterThanOrEqual
UNIT TESTS
DATA TYPES IN PHP
Create Class With Tests
• assertRegExp($pattern, $string [, $message])
• assertNotRegExp
SUMMARY
DATA TYPES IN PHP
SUMMARY
• 8 data types
• string
• integer
• float
• boolean
• array
• object
• null
• resource
DATA TYPES IN PHP
SUMMARY
• Use data types correctly
• Code defensively
• Be aware of automatic type casting
• Prefer strict type checks
• Unit tests to ensure correct values
QUESTIONS?
https://joind.in/talk/6d7f9
SOURCES
DATA TYPES IN PHP
• php.net
• https://phpunit.de/manual/current/en/
• https://getcomposer.org/doc/00-intro.md

More Related Content

What's hot

Java oops PPT
Java oops PPTJava oops PPT
Java oops PPTkishu0005
 
Exception handling c++
Exception handling c++Exception handling c++
Exception handling c++Jayant Dalvi
 
The innerHTML Apocalypse
The innerHTML ApocalypseThe innerHTML Apocalypse
The innerHTML ApocalypseMario Heiderich
 
Abstract Base Class and Polymorphism in C++
Abstract Base Class and Polymorphism in C++Abstract Base Class and Polymorphism in C++
Abstract Base Class and Polymorphism in C++Liju Thomas
 
SWE-401 - 7. Software Design Strategies
SWE-401 - 7. Software Design StrategiesSWE-401 - 7. Software Design Strategies
SWE-401 - 7. Software Design Strategiesghayour abbas
 
OK Google, How Do I Red Team GSuite?
OK Google, How Do I Red Team GSuite?OK Google, How Do I Red Team GSuite?
OK Google, How Do I Red Team GSuite?Beau Bullock
 
Friends function and_classes
Friends function and_classesFriends function and_classes
Friends function and_classesasadsardar
 
Virtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAP
Virtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAPVirtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAP
Virtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAPMichael Coates
 
Object Oriented Concept Static vs. Non Static
Object Oriented Concept Static vs. Non StaticObject Oriented Concept Static vs. Non Static
Object Oriented Concept Static vs. Non StaticOXUS 20
 
Polymorphism in java
Polymorphism in java Polymorphism in java
Polymorphism in java Janu Jahnavi
 
Remote Method Invocation (RMI)
Remote Method Invocation (RMI)Remote Method Invocation (RMI)
Remote Method Invocation (RMI)Peter R. Egli
 

What's hot (20)

Java oops PPT
Java oops PPTJava oops PPT
Java oops PPT
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
java Features
java Featuresjava Features
java Features
 
Exception handling c++
Exception handling c++Exception handling c++
Exception handling c++
 
Php operators
Php operatorsPhp operators
Php operators
 
PHP and Mysql
PHP and MysqlPHP and Mysql
PHP and Mysql
 
The innerHTML Apocalypse
The innerHTML ApocalypseThe innerHTML Apocalypse
The innerHTML Apocalypse
 
Abstract Base Class and Polymorphism in C++
Abstract Base Class and Polymorphism in C++Abstract Base Class and Polymorphism in C++
Abstract Base Class and Polymorphism in C++
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
 
Operating system critical section
Operating system   critical sectionOperating system   critical section
Operating system critical section
 
07. Virtual Functions
07. Virtual Functions07. Virtual Functions
07. Virtual Functions
 
SWE-401 - 7. Software Design Strategies
SWE-401 - 7. Software Design StrategiesSWE-401 - 7. Software Design Strategies
SWE-401 - 7. Software Design Strategies
 
Controls in asp.net
Controls in asp.netControls in asp.net
Controls in asp.net
 
OK Google, How Do I Red Team GSuite?
OK Google, How Do I Red Team GSuite?OK Google, How Do I Red Team GSuite?
OK Google, How Do I Red Team GSuite?
 
Friends function and_classes
Friends function and_classesFriends function and_classes
Friends function and_classes
 
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
 
Virtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAP
Virtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAPVirtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAP
Virtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAP
 
Object Oriented Concept Static vs. Non Static
Object Oriented Concept Static vs. Non StaticObject Oriented Concept Static vs. Non Static
Object Oriented Concept Static vs. Non Static
 
Polymorphism in java
Polymorphism in java Polymorphism in java
Polymorphism in java
 
Remote Method Invocation (RMI)
Remote Method Invocation (RMI)Remote Method Invocation (RMI)
Remote Method Invocation (RMI)
 

Viewers also liked

Data types in php
Data types in phpData types in php
Data types in phpilakkiya
 
High Performance Solution for PHP7
High Performance Solution for PHP7High Performance Solution for PHP7
High Performance Solution for PHP7Xinchen Hui
 
The secret of PHP7's Performance
The secret of PHP7's Performance The secret of PHP7's Performance
The secret of PHP7's Performance Xinchen Hui
 
PHP7.1 New Features & Performance
PHP7.1 New Features & PerformancePHP7.1 New Features & Performance
PHP7.1 New Features & PerformanceXinchen Hui
 
How To Install Apache, MySQL & PHP on Windows Vista
How To Install Apache, MySQL & PHP on Windows VistaHow To Install Apache, MySQL & PHP on Windows Vista
How To Install Apache, MySQL & PHP on Windows VistaMochamad Yusuf
 
[FISL 16] PHP no Campo de Batalha: Segurança Avançada e Programação Defensiva...
[FISL 16] PHP no Campo de Batalha: Segurança Avançada e Programação Defensiva...[FISL 16] PHP no Campo de Batalha: Segurança Avançada e Programação Defensiva...
[FISL 16] PHP no Campo de Batalha: Segurança Avançada e Programação Defensiva...Rafael Jaques
 
從 Php unit 到 ci 持續整合
從 Php unit 到 ci 持續整合從 Php unit 到 ci 持續整合
從 Php unit 到 ci 持續整合Joel Zhong
 
PHP WEB 应用组织与结构
PHP WEB 应用组织与结构PHP WEB 应用组织与结构
PHP WEB 应用组织与结构HonestQiao
 
Grpc go-in-php
Grpc go-in-phpGrpc go-in-php
Grpc go-in-php光照 刘
 
TrainingProgramAtMobileDevTW
TrainingProgramAtMobileDevTWTrainingProgramAtMobileDevTW
TrainingProgramAtMobileDevTWRyan Chung
 
Opensource 是人生的好朋友 2016-07-21
Opensource 是人生的好朋友 2016-07-21Opensource 是人生的好朋友 2016-07-21
Opensource 是人生的好朋友 2016-07-21CQD
 
教學課程Pdf備份
教學課程Pdf備份教學課程Pdf備份
教學課程Pdf備份楷霖 顏
 
APP Development Learning Experience Share - AppCoda
APP Development Learning Experience Share - AppCodaAPP Development Learning Experience Share - AppCoda
APP Development Learning Experience Share - AppCodaRyan Chung
 
Flexbox版面配置
Flexbox版面配置Flexbox版面配置
Flexbox版面配置景智 張
 
UI guide Example
UI guide ExampleUI guide Example
UI guide ExampleHowlin Yang
 
寫出高性能的服務與應用 那些你沒想過的事
寫出高性能的服務與應用 那些你沒想過的事寫出高性能的服務與應用 那些你沒想過的事
寫出高性能的服務與應用 那些你沒想過的事Chieh (Jack) Yu
 

Viewers also liked (20)

Data types in php
Data types in phpData types in php
Data types in php
 
PHP
PHPPHP
PHP
 
High Performance Solution for PHP7
High Performance Solution for PHP7High Performance Solution for PHP7
High Performance Solution for PHP7
 
Php
PhpPhp
Php
 
The secret of PHP7's Performance
The secret of PHP7's Performance The secret of PHP7's Performance
The secret of PHP7's Performance
 
Php.ini
Php.iniPhp.ini
Php.ini
 
PHP7.1 New Features & Performance
PHP7.1 New Features & PerformancePHP7.1 New Features & Performance
PHP7.1 New Features & Performance
 
How To Install Apache, MySQL & PHP on Windows Vista
How To Install Apache, MySQL & PHP on Windows VistaHow To Install Apache, MySQL & PHP on Windows Vista
How To Install Apache, MySQL & PHP on Windows Vista
 
PHP
PHPPHP
PHP
 
[FISL 16] PHP no Campo de Batalha: Segurança Avançada e Programação Defensiva...
[FISL 16] PHP no Campo de Batalha: Segurança Avançada e Programação Defensiva...[FISL 16] PHP no Campo de Batalha: Segurança Avançada e Programação Defensiva...
[FISL 16] PHP no Campo de Batalha: Segurança Avançada e Programação Defensiva...
 
從 Php unit 到 ci 持續整合
從 Php unit 到 ci 持續整合從 Php unit 到 ci 持續整合
從 Php unit 到 ci 持續整合
 
PHP WEB 应用组织与结构
PHP WEB 应用组织与结构PHP WEB 应用组织与结构
PHP WEB 应用组织与结构
 
Grpc go-in-php
Grpc go-in-phpGrpc go-in-php
Grpc go-in-php
 
TrainingProgramAtMobileDevTW
TrainingProgramAtMobileDevTWTrainingProgramAtMobileDevTW
TrainingProgramAtMobileDevTW
 
Opensource 是人生的好朋友 2016-07-21
Opensource 是人生的好朋友 2016-07-21Opensource 是人生的好朋友 2016-07-21
Opensource 是人生的好朋友 2016-07-21
 
教學課程Pdf備份
教學課程Pdf備份教學課程Pdf備份
教學課程Pdf備份
 
APP Development Learning Experience Share - AppCoda
APP Development Learning Experience Share - AppCodaAPP Development Learning Experience Share - AppCoda
APP Development Learning Experience Share - AppCoda
 
Flexbox版面配置
Flexbox版面配置Flexbox版面配置
Flexbox版面配置
 
UI guide Example
UI guide ExampleUI guide Example
UI guide Example
 
寫出高性能的服務與應用 那些你沒想過的事
寫出高性能的服務與應用 那些你沒想過的事寫出高性能的服務與應用 那些你沒想過的事
寫出高性能的服務與應用 那些你沒想過的事
 

Similar to Data Types In PHP

Similar to Data Types In PHP (20)

Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010
 
Php
PhpPhp
Php
 
Intro to PHP
Intro to PHPIntro to PHP
Intro to PHP
 
PHP Basics and Demo HackU
PHP Basics and Demo HackUPHP Basics and Demo HackU
PHP Basics and Demo HackU
 
Starting Out With PHP
Starting Out With PHPStarting Out With PHP
Starting Out With PHP
 
Zend Certification Preparation Tutorial
Zend Certification Preparation TutorialZend Certification Preparation Tutorial
Zend Certification Preparation Tutorial
 
Marc’s (bio)perl course
Marc’s (bio)perl courseMarc’s (bio)perl course
Marc’s (bio)perl course
 
05php
05php05php
05php
 
PHP-04-Arrays.ppt
PHP-04-Arrays.pptPHP-04-Arrays.ppt
PHP-04-Arrays.ppt
 
PHP for hacks
PHP for hacksPHP for hacks
PHP for hacks
 
Intro to Perl and Bioperl
Intro to Perl and BioperlIntro to Perl and Bioperl
Intro to Perl and Bioperl
 
Bioinformatica p6-bioperl
Bioinformatica p6-bioperlBioinformatica p6-bioperl
Bioinformatica p6-bioperl
 
Dev traning 2016 basics of PHP
Dev traning 2016   basics of PHPDev traning 2016   basics of PHP
Dev traning 2016 basics of PHP
 
Drupal Form API 101 (PHP) - DrupalCamp LA 2012
Drupal Form API 101 (PHP) - DrupalCamp LA 2012Drupal Form API 101 (PHP) - DrupalCamp LA 2012
Drupal Form API 101 (PHP) - DrupalCamp LA 2012
 
Overview changes in PHP 5.4
Overview changes in PHP 5.4Overview changes in PHP 5.4
Overview changes in PHP 5.4
 
Bioinformatics p5-bioperl v2013-wim_vancriekinge
Bioinformatics p5-bioperl v2013-wim_vancriekingeBioinformatics p5-bioperl v2013-wim_vancriekinge
Bioinformatics p5-bioperl v2013-wim_vancriekinge
 
MIND sweeping introduction to PHP
MIND sweeping introduction to PHPMIND sweeping introduction to PHP
MIND sweeping introduction to PHP
 
php fundamental
php fundamentalphp fundamental
php fundamental
 
Php introduction with history of php
Php introduction with history of phpPhp introduction with history of php
Php introduction with history of php
 
php
phpphp
php
 

More from Mark Niebergall

Filesystem Management with Flysystem - php[tek] 2023
Filesystem Management with Flysystem - php[tek] 2023Filesystem Management with Flysystem - php[tek] 2023
Filesystem Management with Flysystem - php[tek] 2023Mark Niebergall
 
Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023Mark Niebergall
 
Filesystem Management with Flysystem at PHP UK 2023
Filesystem Management with Flysystem at PHP UK 2023Filesystem Management with Flysystem at PHP UK 2023
Filesystem Management with Flysystem at PHP UK 2023Mark Niebergall
 
Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022Mark Niebergall
 
Unit Testing from Setup to Deployment
Unit Testing from Setup to DeploymentUnit Testing from Setup to Deployment
Unit Testing from Setup to DeploymentMark Niebergall
 
BDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and BehatBDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and BehatMark Niebergall
 
BDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and BehatBDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and BehatMark Niebergall
 
Relational Database Design Bootcamp
Relational Database Design BootcampRelational Database Design Bootcamp
Relational Database Design BootcampMark Niebergall
 
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)Mark Niebergall
 
Debugging PHP with Xdebug - PHPUK 2018
Debugging PHP with Xdebug - PHPUK 2018Debugging PHP with Xdebug - PHPUK 2018
Debugging PHP with Xdebug - PHPUK 2018Mark Niebergall
 
Advanced PHP Simplified - Sunshine PHP 2018
Advanced PHP Simplified - Sunshine PHP 2018Advanced PHP Simplified - Sunshine PHP 2018
Advanced PHP Simplified - Sunshine PHP 2018Mark Niebergall
 
Defensive Coding Crash Course Tutorial
Defensive Coding Crash Course TutorialDefensive Coding Crash Course Tutorial
Defensive Coding Crash Course TutorialMark Niebergall
 
Inheritance: Vertical or Horizontal
Inheritance: Vertical or HorizontalInheritance: Vertical or Horizontal
Inheritance: Vertical or HorizontalMark Niebergall
 
Cybersecurity State of the Union
Cybersecurity State of the UnionCybersecurity State of the Union
Cybersecurity State of the UnionMark Niebergall
 
Cryptography With PHP - ZendCon 2017 Workshop
Cryptography With PHP - ZendCon 2017 WorkshopCryptography With PHP - ZendCon 2017 Workshop
Cryptography With PHP - ZendCon 2017 WorkshopMark Niebergall
 
Defensive Coding Crash Course - ZendCon 2017
Defensive Coding Crash Course - ZendCon 2017Defensive Coding Crash Course - ZendCon 2017
Defensive Coding Crash Course - ZendCon 2017Mark Niebergall
 
Leveraging Composer in Existing Projects
Leveraging Composer in Existing ProjectsLeveraging Composer in Existing Projects
Leveraging Composer in Existing ProjectsMark Niebergall
 

More from Mark Niebergall (20)

Filesystem Management with Flysystem - php[tek] 2023
Filesystem Management with Flysystem - php[tek] 2023Filesystem Management with Flysystem - php[tek] 2023
Filesystem Management with Flysystem - php[tek] 2023
 
Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023Leveling Up With Unit Testing - php[tek] 2023
Leveling Up With Unit Testing - php[tek] 2023
 
Filesystem Management with Flysystem at PHP UK 2023
Filesystem Management with Flysystem at PHP UK 2023Filesystem Management with Flysystem at PHP UK 2023
Filesystem Management with Flysystem at PHP UK 2023
 
Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022
 
Developing SOLID Code
Developing SOLID CodeDeveloping SOLID Code
Developing SOLID Code
 
Unit Testing from Setup to Deployment
Unit Testing from Setup to DeploymentUnit Testing from Setup to Deployment
Unit Testing from Setup to Deployment
 
Stacking Up Middleware
Stacking Up MiddlewareStacking Up Middleware
Stacking Up Middleware
 
BDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and BehatBDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and Behat
 
BDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and BehatBDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and Behat
 
Hacking with PHP
Hacking with PHPHacking with PHP
Hacking with PHP
 
Relational Database Design Bootcamp
Relational Database Design BootcampRelational Database Design Bootcamp
Relational Database Design Bootcamp
 
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
 
Debugging PHP with Xdebug - PHPUK 2018
Debugging PHP with Xdebug - PHPUK 2018Debugging PHP with Xdebug - PHPUK 2018
Debugging PHP with Xdebug - PHPUK 2018
 
Advanced PHP Simplified - Sunshine PHP 2018
Advanced PHP Simplified - Sunshine PHP 2018Advanced PHP Simplified - Sunshine PHP 2018
Advanced PHP Simplified - Sunshine PHP 2018
 
Defensive Coding Crash Course Tutorial
Defensive Coding Crash Course TutorialDefensive Coding Crash Course Tutorial
Defensive Coding Crash Course Tutorial
 
Inheritance: Vertical or Horizontal
Inheritance: Vertical or HorizontalInheritance: Vertical or Horizontal
Inheritance: Vertical or Horizontal
 
Cybersecurity State of the Union
Cybersecurity State of the UnionCybersecurity State of the Union
Cybersecurity State of the Union
 
Cryptography With PHP - ZendCon 2017 Workshop
Cryptography With PHP - ZendCon 2017 WorkshopCryptography With PHP - ZendCon 2017 Workshop
Cryptography With PHP - ZendCon 2017 Workshop
 
Defensive Coding Crash Course - ZendCon 2017
Defensive Coding Crash Course - ZendCon 2017Defensive Coding Crash Course - ZendCon 2017
Defensive Coding Crash Course - ZendCon 2017
 
Leveraging Composer in Existing Projects
Leveraging Composer in Existing ProjectsLeveraging Composer in Existing Projects
Leveraging Composer in Existing Projects
 

Recently uploaded

Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfIdiosysTechnologies1
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 

Recently uploaded (20)

Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdf
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 

Data Types In PHP

  • 1. DATA TYPES IN PHP MARK NIEBERGALL https://joind.in/talk/6d7f9
  • 2. ABOUT MARK NIEBERGALL DATA TYPES IN PHP • PHP since 2005 • Masters degree in MIS • Senior Software Engineer • Team Lead • Drug screening project • President of Utah PHP User Group (UPHPU) • SSCP, CSSLP Certified and SME for (ISC)2 • PHP, databases, JavaScript • Drones, fishing, skiing, father, husband
  • 5. UPHPU DATA TYPES IN PHP • Third Thursday of each month at 7pm • Venue is Vivint in Lehi (3401 Ashton Blvd) • Variety of PHP related topics • Mostly local speakers, occasional traveling speaker • Networking with other developers, companies • Professional development • uphpu.org
  • 7. OVERVIEW DATA TYPES IN PHP • Identify and define each type • Proper usage • Type juggling • Data type traps • Defensive coding • Unit tests
  • 8. CAN YOU NAME ALL THE DATA TYPES?
  • 9. IDENTIFY AND DEFINE DATA TYPES IN PHP • 8 data types • 4 scalar • 2 compound • 2 special
  • 10. IDENTIFY AND DEFINE DATA TYPES IN PHP • Scalar • string • integer • float (double) • boolean • Compound • array • object • Special • null • resource
  • 11. IDENTIFY AND DEFINE DATA TYPES IN PHP Scalar Compound Special string array null integer object resource float boolean
  • 12. IDENTIFY AND DEFINE DATA TYPES IN PHP Scalar Compound Special ‘Hello world’ [1, 2, 3] null 123 new X fopen 12.34 TRUE
  • 14. IDENTIFY AND DEFINE DATA TYPES IN PHP String • $var = ‘Hello world!’; • Series of characters • Up to 2GB • Scalar type • is_string
  • 15. IDENTIFY AND DEFINE DATA TYPES IN PHP String • $name = ‘Alice’; • Single quote: $var = ‘Hello $name’; • Output: Hello $name
  • 16. IDENTIFY AND DEFINE DATA TYPES IN PHP String • $name = ‘Alice’; • Double quote: $var = “Hello $name”; • Output: Hello Alice
  • 17. IDENTIFY AND DEFINE DATA TYPES IN PHP String • $name = ‘Alice’; • Heredoc: $var = <<<EOD
 Hello $name
 EOD; • Output: Hello Alice
  • 18. IDENTIFY AND DEFINE DATA TYPES IN PHP String • $name = ‘Alice’; • Nowdoc: $var = <<<‘EOD’
 Hello $name
 EOD; • Output: Hello $name
  • 19. IDENTIFY AND DEFINE DATA TYPES IN PHP String • $name = ‘Alice’; • $var = ‘Hello ‘ . $name; • $var = “Hello $name”; • $var = “Hello {$name}”; • $var = “Hello {$person[‘name’]}”; • $var = “Hello {$person->name}”; • Output: Hello Alice
  • 20. IDENTIFY AND DEFINE DATA TYPES IN PHP String • $escaped = ‘t’; • Output: 't' • $escaped = “t”; • Output: ‘ ‘
  • 21. IDENTIFY AND DEFINE DATA TYPES IN PHP
  • 23. IDENTIFY AND DEFINE DATA TYPES IN PHP Integer • $number = 16; • Scalar type • Positive or negative: -16 or 16 • is_int or is_integer
  • 24. IDENTIFY AND DEFINE DATA TYPES IN PHP Integer • Decimal (base 10): 16 • Hexadecimal (base 16, leading 0x): 0x10 • Octal (base 8, leading 0): 020 • Binary (base 2, leading 0b): 0b10000
  • 25. IDENTIFY AND DEFINE DATA TYPES IN PHP Integer • Max 2,147,483,647 on 32-bit system • Max 9,223,372,036,854,775,807 on 64-bit system • Becomes a float if too big
  • 26. IDENTIFY AND DEFINE DATA TYPES IN PHP Integer • Automatically converted to float in math where result is not a whole number • 16 / 2 = integer 8 • 16 / 3 = float 5.3333333333333 • (int) ((0.1 + 0.7) * 10) = (int) 7 • Precision with floats • Float to integer always rounded toward zero
  • 27. FLOAT
  • 28. IDENTIFY AND DEFINE DATA TYPES IN PHP Float • $var = 12.34; • Scalar type • Double • Floating-point number • Real numbers • is_float, is_double, or is_real
  • 29. IDENTIFY AND DEFINE DATA TYPES IN PHP Float • Uses IEEE 754 standard for calculations • Arithmetic formats • Interchange formats • Rounding rules • Operations • Exception handling (overflow, divide by zero)
  • 30. IDENTIFY AND DEFINE DATA TYPES IN PHP Float • $var = 12.34 • $var = 12.3e4 • $var = 12E-3
  • 31. IDENTIFY AND DEFINE DATA TYPES IN PHP Float • Precision varies by platform • Limited precision • Uses base 2 under the hood • Prone to accuracy problems
  • 32. IDENTIFY AND DEFINE DATA TYPES IN PHP Float • (0.1 + 0.7) * 10 = 7.9999… • floor((0.1 + 0.7) * 10) = 7
  • 33. IDENTIFY AND DEFINE DATA TYPES IN PHP Float • Use libraries for float math like BC Math or gmp • bcadd, bcmul • gmp_add, gmp_mul
  • 34. IDENTIFY AND DEFINE DATA TYPES IN PHP Float • BCMath Arbitrary Precision Mathematics • bcxxx($leftOperand, $rightOperand [, $scale]) • bcscale($scale) • bcadd($a, $b) • bcmul($a, $b) • bcdiv($a, $b)
  • 35. IDENTIFY AND DEFINE DATA TYPES IN PHP Float • GNU Multiple Precision • gmp_xxx($leftOperand, $rightOperand [, $rounding]) • GMP_ROUND_ZERO • GMP_ROUND_PLUSINF • GMP_ROUND_MINUSINF • gmp_init($number) • gmp_add($a, $b) • gmp_mul($a, $b) • gmp_div($a, $b, GMP_ROUND_ZERO)
  • 36. IDENTIFY AND DEFINE DATA TYPES IN PHP Float • Keep precision in mind • Use libraries for accuracy
  • 38. IDENTIFY AND DEFINE DATA TYPES IN PHP Boolean • $var = true; • Scalar type • Boolean or Bool • Only two possible values: true or false • is_bool
  • 39. IDENTIFY AND DEFINE DATA TYPES IN PHP Boolean • $var = true; • 0 == false • 1 == true • 2 == true • -1 == true • 3.45 == true • ‘abc’ == true • ‘false’ == true
  • 40. IDENTIFY AND DEFINE DATA TYPES IN PHP Boolean • true === true • false === false
  • 41. IDENTIFY AND DEFINE DATA TYPES IN PHP Boolean • Good to work with • Simplify checks
  • 42. ARRAY
  • 43. IDENTIFY AND DEFINE DATA TYPES IN PHP Array • $var = [1, 2, 3]; • Compound type • is_array
  • 44. IDENTIFY AND DEFINE DATA TYPES IN PHP Array • $var = [1, 2, 3, 4.56]; • $var = [‘abc’, ‘xyz’]; • $var = [‘fruit’ => ‘apple’, ‘vegetable’ => ‘carrot’]; • $var = array(‘key’ => ‘value’); • $var[‘key’] = ‘value’; • $var[] = ‘value’; • $var{123} = ‘value’; • $var = explode(‘,’, $csv);
  • 45. IDENTIFY AND DEFINE DATA TYPES IN PHP Array • Ordered map • Keys and values • Keys are integer or string • Value can be of any data type • If adding value to array then key = max numeric key + 1 where max numeric key is max that has existed since last re- index
  • 46. IDENTIFY AND DEFINE DATA TYPES IN PHP Data Type Key Key Cast As string ‘abc123' ‘abc123' string ‘123’ 123 float 12.34 12 bool true 1 null null ‘' array […] Illegal offset object new X Illegal offset
  • 47. IDENTIFY AND DEFINE DATA TYPES IN PHP Array • foreach ($array as $key => $value) { … } • foreach ($array as &$value) { … } • for ($i = 0; $i < count($array); $i++) { … }
  • 48. IDENTIFY AND DEFINE DATA TYPES IN PHP Array • Many useful array functions • ksort • asort • array_keys • array_key_exists
  • 49. IDENTIFY AND DEFINE DATA TYPES IN PHP Array • array_merge • array_intersect • array_column
  • 50. IDENTIFY AND DEFINE DATA TYPES IN PHP Array • array_push • array_pop • array_shift • array_unshift • array_splice
  • 51. IDENTIFY AND DEFINE DATA TYPES IN PHP Array • Use wisely • Use available array functions • Avoid overly nested arrays • Watch key casting
  • 53. IDENTIFY AND DEFINE DATA TYPES IN PHP Object • $var = new X; • Compound type • is_class • instanceof
  • 54. IDENTIFY AND DEFINE DATA TYPES IN PHP Object • $var = new X; • $var = new X($value); • $var->doSomething($parameter); • $var::staticMethod(); • $var::SOME_CONSTANT;
  • 55. IDENTIFY AND DEFINE DATA TYPES IN PHP Object • Constants • Properties • Methods • Magic methods • Visibility modifiers • Final keyword
  • 56. IDENTIFY AND DEFINE DATA TYPES IN PHP Object
 
 class RainbowTrout extends Fish implements MarineLife {
 use Camouflage; const SPECIES = ‘Rainbow Trout’;
 protected $age; public function swim() { … } protected function breathe() { … }
 public function eat(Food $food) { … } private function ponder(Thought $thought) { … } }
  • 57. IDENTIFY AND DEFINE DATA TYPES IN PHP Object • Abstract • Interface • Trait
  • 58. IDENTIFY AND DEFINE DATA TYPES IN PHP Object • Abstract • Vertical inheritance via extend • class Dog extends Canine • Is X a Y? • Code reusability • Ensure functionality • Only extend one class at a time • Can have multiple levels • Cannot be instantiated
  • 59. IDENTIFY AND DEFINE DATA TYPES IN PHP Object • Abstract • abstract Canine {
 public function wagTail() { … }
 abstract public function run();
 } • class Dog extends Canine {
 public function run() { … }
 } • $dog = new Dog;
 $dog->wagTail();
 $dog->run();
  • 60. IDENTIFY AND DEFINE DATA TYPES IN PHP Object • Interface • Class implements an interface • Define required method signatures • Does not define content of methods • Class defines the implementation • What class needs to do, not how to do it
  • 61. IDENTIFY AND DEFINE DATA TYPES IN PHP Object • Interface • interface PlayFetch {
 public function retrieveItem(Item $item);
 } • class Dog implements PlayFetch {
 public function retrieveItem(Item $item) { … }
 } • class Child extends Human implements PlayFetch, TakeNap {
 public function retrieveItem(Item $item) { … }
 public function fallAsleep() { … }
 }
  • 62. IDENTIFY AND DEFINE DATA TYPES IN PHP Object • Trait • Characteristic • Attribute • Reusable group functionality • Horizontal inheritance • Cannot be instantiated • Can use multiple traits • Vertical inheritance considerations • Dependency injection considerations
  • 63. IDENTIFY AND DEFINE DATA TYPES IN PHP Object • Trait • trait Hair {
 protected $color;
 public function setHairColor($color) { … }
 public function washHair($shampoo) { … }
 } • class Cat extends Feline { use Hair; } • $cat = new Cat;
 $cat->setHairColor(‘grey’);
 $cat->washHair($shampoo);
  • 64. IDENTIFY AND DEFINE DATA TYPES IN PHP Object • Type hinting • Method signatures • public function doSomething(X $x, array $y) { … } • Doc blocks • /** @var integer */ • Method return type hint as of PHP 7 • public function sum($a, $b): integer { … }
  • 65. IDENTIFY AND DEFINE DATA TYPES IN PHP Object • Heavily used with PHP applications • Advanced functionality • Inheritance • Code reuse
  • 66. NULL
  • 67. IDENTIFY AND DEFINE DATA TYPES IN PHP Null • $var; • $var = null; • Special type • Represents no value • is_null
  • 68. IDENTIFY AND DEFINE DATA TYPES IN PHP Null • public function doNothing() {} • $value = $object->doNothing();
  • 69. IDENTIFY AND DEFINE DATA TYPES IN PHP Null • $value = null; • Works: empty($value) === true • Best: is_null($value) === true
  • 70. IDENTIFY AND DEFINE DATA TYPES IN PHP Null • unset($value) • $value becomes null
  • 72. IDENTIFY AND DEFINE DATA TYPES IN PHP Resource • Special type • Reference to an external resource • Database connection • Open files • Certificates • Image canvas • get_resource_type • is_resource
  • 73. IDENTIFY AND DEFINE DATA TYPES IN PHP Resource • $resource = new mysqli(…); • $handle = fopen($fileName, ‘r’); • $privateKey = openssl_pkey_new([…]);
  • 74. IDENTIFY AND DEFINE DATA TYPES IN PHP Resource • Can be closed manually • Automatically closed when no more references • Memory freed by garbage collector • Exception to the rule are persistent database connections
  • 75. IDENTIFY AND DEFINE DATA TYPES IN PHP Resource • Cannot cast to resource
  • 77. DEFENSIVE CODING DATA TYPES IN PHP Defensive Coding • Hope for the best and prepare for the worst • Type hinting • Type checking • Type casting
  • 79. DEFENSIVE CODING DATA TYPES IN PHP Type Hinting • Use heavily • Provides documentation • Supports ‘Fail fast’ • Ensures data is of correct type or instance • Makes code easier to read and understand by peers
  • 80. DEFENSIVE CODING DATA TYPES IN PHP Type Hinting • Method parameters • protected function doSomething(int $a, float $b, bool $c, array $d, X $x) { … } • Method return • private function doOther(SomeClass $someClass): someClass { … }
  • 81. DEFENSIVE CODING DATA TYPES IN PHP Type Checking • Use proper data type checks • is_null instead of empty • is_float instead of is_numeric • === when possible • instanceof checks • count vs empty
  • 82. DEFENSIVE CODING DATA TYPES IN PHP Comparison Operators Loose Strict Operator == === Type Check No Yes Type Conversion Yes No
  • 83. DEFENSIVE CODING DATA TYPES IN PHP Type Casting • Automatic • Manual
  • 84. DEFENSIVE CODING DATA TYPES IN PHP Type Casting • Automatic • PHP is a loosely typed language • Variable data type can change • Particularly with going to string or integer • Unintentionally introduce defects • ‘1’ + ‘2’ === 3 • 1 + ‘1 way’ === 2
  • 85. DEFENSIVE CODING DATA TYPES IN PHP Type Casting • Manual • Cast variable as a specific type • (int) false === 0 • (int) 12.34 === 12 • (int) ‘123abc’ === 123
  • 86. DEFENSIVE CODING DATA TYPES IN PHP Type Casting • Manual • Cast variable as a specific type • (string) false === ‘’ • (string) true === ‘1’ • (string) 12.34 === ’12.34’
  • 87. DEFENSIVE CODING DATA TYPES IN PHP Type Casting • Manual • Cast variable as a specific type • (bool) ‘false’ === true • (boolean) 1 === true
  • 88. DEFENSIVE CODING DATA TYPES IN PHP Type Casting • Manual • Cast variable as a specific type • (float) ’12.34’ === 12.34 • (double) 12 === 12 • (real) ‘’ === 0
  • 89. DEFENSIVE CODING DATA TYPES IN PHP Type Casting • Manual • Cast variable as a specific type • (array) ‘scalar’ === [‘scalar’] • (array) new Exception === [‘* message’ => ‘’, ‘Exception string’ => ‘’, ‘* code’ => 0, ‘* file’ => ‘/path/to/file.php’, ‘* line’ => 123, ‘Exception trace’ => […], ‘Exception previous’ => null] • Classname key for private • Asterisk * for protected
  • 90. DEFENSIVE CODING DATA TYPES IN PHP Type Casting • Manual • Cast variable as a specific type • (object) [1, 2, 3] becomes stdClass{public 0 = 1; public 1 = 2; public 3 = 2;} • (object) ‘something’ becomes stdClass{public ‘scalar’ = ‘something’;} • (object) null becomes stdClass{}
  • 91. DEFENSIVE CODING DATA TYPES IN PHP Type Casting • Manual • Cast variable as a specific type • (unset) ‘anything’ === null • (unset) $value === null • returns null • $value retains existing value
  • 93. UNIT TESTS DATA TYPES IN PHP Unit Tests • Automated way to test code • Data type checks • Value checks • Code behaves as expected
  • 94. UNIT TESTS DATA TYPES IN PHP Setup • Via composer • Add to composer.json: • “require-dev”: {“phpunit/phpunit”: “5.4.*”} • composer update • Via download • wget https://phar.phpunit.de/phpunit.phar
 chmod +x phpunit.phar
 sudo mv phpunit.phar /usr/local/bin/phpunit
  • 95. UNIT TESTS DATA TYPES IN PHP Create Class With Tests • Create /tests/ directory • Files named *Test.php • If using composer • require_once __DIR__ . ‘/../vendor/autoload.php’; • use PHPUnitFrameworkTestCase;
 class FilenameTest extends TestCase { … }
  • 96. UNIT TESTS DATA TYPES IN PHP Create Class With Tests • Focus today is on data types • Data providers to provide test data sets
  • 97. UNIT TESTS DATA TYPES IN PHP Create Class With Tests • assertEquals($expected, $actual [, $message]) • Value is equal • No data type check • == • assertSame($expected, $actual [, $message]) • Value is equal • Data type is same • ===
  • 98. UNIT TESTS DATA TYPES IN PHP Create Class With Tests • Use setUp to set class • protected function setUp() {
 parent::setup();
 $this->intMath = new IntMath;
 }
  • 99. UNIT TESTS DATA TYPES IN PHP Create Class With Tests • Use data providers to use test data sets • /** @dataprovider intAdditionProvider */
 public function testAddInts($a, $b, $expected) {
 $this->assertSame($expected, $this->IntMath->add($a, $b));
 }
 public function intAdditionProvider() {
 return [
 [0, 0, 0],
 [1, 2, 3],
 [-1, 1, 0]
 ];
 }
  • 100. UNIT TESTS DATA TYPES IN PHP Create Class With Tests • assertContains($needle, $haystack [, $message, $ignoreCase]) • Value (needle) exists in haystack • Defaults to not ignore case • assertContainsOnly($type, $haystack [, $isNativeType, $message]) • Is type the only data type in the haystack
  • 101. UNIT TESTS DATA TYPES IN PHP Create Class With Tests • assertFalse($condition [, $message]) • assertNotFalse($condition [, $message]) • assertTrue($condition [, $message]) • assertNotTrue($condition [, $message])
  • 102. UNIT TESTS DATA TYPES IN PHP Create Class With Tests • assertNull($variable [, $message]) • assertNotNull($variable [, $message])
  • 103. UNIT TESTS DATA TYPES IN PHP Create Class With Tests • assertInstanceOf($expected, $actual [, $message]) • assertContainsOnlyInstancesOf($classname, $haystack [, $message]) • Instance checks in array or Traversable
  • 104. UNIT TESTS DATA TYPES IN PHP Create Class With Tests • assertLessThan • assertLessThanOrEqual • assertGreaterThan • assertGreaterThanOrEqual
  • 105. UNIT TESTS DATA TYPES IN PHP Create Class With Tests • assertRegExp($pattern, $string [, $message]) • assertNotRegExp
  • 107. DATA TYPES IN PHP SUMMARY • 8 data types • string • integer • float • boolean • array • object • null • resource
  • 108. DATA TYPES IN PHP SUMMARY • Use data types correctly • Code defensively • Be aware of automatic type casting • Prefer strict type checks • Unit tests to ensure correct values
  • 110. SOURCES DATA TYPES IN PHP • php.net • https://phpunit.de/manual/current/en/ • https://getcomposer.org/doc/00-intro.md