SlideShare a Scribd company logo
UNKNOWN FEATURES OF
PHP
or less known ;)
ABOUT ME
CERTIFIED
PHP ENGINEER
CERTIFIED
A R C H I T E CT
2
Łukasz Witczak
10+ yrs experience
STRICTTYPED PHP?
IS IT POSSIBLETO WRITE
STRICTLYTYPED PHP CODE?
Never trust accepted answer at stackoverflow
STATIC/DYNAMIC
STRICT/WEAK?
• Static/Dynamic typing is about when type
information is aquired (at compiletime or at
runtime)
• Strong/Weak typing is about how strictly types
are distinguished (e.g. whether the language tries
to do implicit conversion from strings to
numbers).
WEAKTYPING AND STRICT
TYPING
• Fully strict type checking where no conversion happens (Go,
Facebook's Hack)
• Widening primitive type checking where “safe” conversions
happen (Java, Pascal, PHP Objects).
• Weak type checking which all conversions are allowed, with
possible warnings raised (which is used to a limited extent by C,
C#, C++ andVisual Basic, PHP scalars?)
“DESPITE THEIR PRODUCTIVITY
ADVANTAGES, DYNAMIC
LANGUAGES MAY NOT BE THE BEST
CHOICES FOR ALL APPLICATIONS,
PARTICULARLY FOR VERY LARGE
CODE BASES AND HIGH-
PERFORMANCE APPLICATIONS.”
http://docs.zephir-lang.com/en/latest/motivation.html#statically-typed-
versus-dynamically-typed-languages
TYPE HINTING PHP 5+
TYPE HINTING PHP7
SCALARTYPE HINTS
FOR PHP 5.4+
• string
• integer, int
• float, double
• boolean, bool
• resource
https://pecl.php.net/package/strict
LIMITATIONS
• “Internal functions cannot use strict hints, only user
code is supported.”
• “Because the parser detects scalar hints as classes,
they cannot have default values.” This was written before we knew that
PHP7 would get strict parameter and
return typing.

The best thing to do now is probably
make this a close approximation of
compatibility for PHP5 ... I'm super
busy right now and this isn't really a
priority …
–Joe Watkins
“ I'm super busy right now and this isn't really a
priority ...”
FUTURE
SPL_TYPES
http://php.net/manual/en/intro.spl-types.php
“This extension aims at helping people making PHP a
stronger typed language and can be a good alternative
to scalar type hinting.”
SPL_TYPES
demo?
SPL_TYPES
• Total downloads: 53,633
ZEPHIR
Zephir, an open source, high-level language designed to ease the
creation and maintainability of extensions for PHP with a focus on type
and memory safety.
ZEPHIR STATICTYPES
• boolean A boolean expresses a truth value. It can be either ‘true’ or ‘false’.
• integer Signed integers.At least 16 bits in size.
• unsigned integer Unsigned integers.At least 16 bits in size.
• char Smallest addressable unit of the machine that can contain basic character set.
• unsigned char Same size as char, but guaranteed to be unsigned.
• long Long signed integer type.At least 32 bits in size.
• unsigned long Same as long, but unsigned.
• float/double Double precision floating-point type.The size is platform-dependent.
• string A string is series of characters, where a character is the same as a byte.
• array An structure that can be used as hash, map, dictionary, collection, stack, etc.
ZEPHIR UNSIGNED INT
ZEPHIR CHAR AND STRING
ASYNCHRONOUS PHP
cooperative multitasking
SYNCHRONOUS
Tasks
Time
0 150 300 450 600
Task #1 Task #2 Task #3
ASYNCHRONOUS
Tasks
Time [ms]
0 75 150 225 300
Task #1 Task #2 Task #3
NODE.JS
EVENT-DRIVEN, NON-
BLOCKING I/O WITH PHP
pond 3mln pobrań promise
• StreamSelectLoop - out of the box
• LibEventLoop -This uses the libevent pecl extension with a
number of system-specific backends (epoll, kqueue).
• LibEvLoop -This uses the libev pecl extension (github). It
supports the same backends as libevent.
• ExtEventLoop -This uses the event pecl extension. It
supports the same backends as libevent
loop
by Marc J. Schmidt
• http://marcjschmidt.de/blog/2014/02/08/php-
high-performance.html
• https://github.com/php-pm/php-pmLibEvLoop
• http://reactphp.org/
• https://github.com/reactphp
resources
https://github.com/ratchetphp/Ratchet
ratchetphp/Ratchet
Ratchet is a loosely coupled PHP library providing developers with
tools to create real time, bi-directional applications between clients
and servers over WebSockets.
http://socketo.me/
• Supports the RFC6455, HyBi-10+, and Hixie76 protocol
versions (at the same time)
• Tested on Chrome 13+, Firefox 6+, Safari 5+, iOS 4.2+, IE 8+
• Ratchet passes the Autobahn Testsuite (non-binary
messages)
https://github.com/nrk/predis-async
Predis/Async
https://github.com/bixuehujin/reactphp-mysql
react/mysql
• mysql (with non blocking I/O) driver for
reactphp,
• It is written in pure PHP - implemented the
mysql protocol.
react/mysql
• Installs: 530
• Stars: 58
• Watchers: 11
• Forks: 13
• Open Issues: 3
react/mysql
https://github.com/reactphp/filesystem
react/filesystem
• Evented filesystem access utilising
asyncronous POSIX I/O by means of
libEIO C library
• requires http://php.net/eio extension
react/filesystem
react/filesystem
• Installs: 1 014
• Dependents: 2
• Stars: 33
• Watchers: 10
• Forks: 7
• Open Issues: 5
filesystem non-blocking I/O
HACK LANG
• Async,Await,Awaitable
HACK LANG
HACK LANG
od hhvm 3.6 - obecnie hhvm 3.10
ASYNC DB QUERIES
ASYNC MYSQL
mysqli::reap_async_query
mysqli_reap_async_query
ASYNC POSTGRESQL
ASYNC HTTP
CURL_MULTI
BUZZ
BUZZMULTI
BUZZVS BUZZMULTI
Time[ms]
0
1250
2500
3750
5000
Sync Multi
Trudność w gromadzeniu requestów
GUZZLE 5
END OF SCRIPT
http://www.rfc-editor.org/rfc/rfc1945.txt 200
http://www.rfc-editor.org/rfc/rfc7540.txt 200
http://www.rfc-editor.org/rfc/rfc2068.txt 200
composer require “guzzlehttp/guzzle:~5.3”
THREADS
YES!
PHP Threads…
…and NOT
pcntl_fork
https://pecl.php.net/package/pthreads
https://github.com/krakjoe/pthreads
http://php.net/pthreads
PTHREADS
• Object Orientated (like Java)
• Easy to use an safety built in (no MUTEX)
• High level implementation of POSIX threads
• Well documented
PTHREADS EXAMPLE
PTHREADS
• Stable since 2013-09-08 (0.0.45)
• Over 163,000 downloads (from PECL)
• Heavily developed: (35 releases)
• Mature
PTHREADS
• http://pthreads.org/
• https://gist.github.com/krakjoe/9384409
• https://gist.github.com/krakjoe/6437782
read first
PTHREADS
Not for web
–Joe Watkins
“(…)you can't use pthreads safely and sensibly
anywhere but CLI.”
PTHREADS
PHP-CLI YES!
THREDS ARE HARD
• https://web.stanford.edu/~ouster/cgi-bin/papers/
threads.pdf
OPERATOR OVERLOADING
OPERATOR OVERLOADING IN PHP
EXTENSIONS
OPERATOR OVERLOADING IN PHP
EXTENSIONS
THANKYOU
https://joind.in/16171
@woocashw
Unknown features of PHP

More Related Content

What's hot

Languages formanandmachine
Languages formanandmachineLanguages formanandmachine
Languages formanandmachine
Gireesh Punathil
 
NLP techniques for log analysis
NLP techniques for log analysisNLP techniques for log analysis
NLP techniques for log analysis
Jacob Perkins
 
Python Intro For Managers
Python Intro For ManagersPython Intro For Managers
Python Intro For Managers
Atul Shridhar
 
Php
PhpPhp
NDC London 2014: Erlang Patterns Matching Business Needs
NDC London 2014: Erlang Patterns Matching Business NeedsNDC London 2014: Erlang Patterns Matching Business Needs
NDC London 2014: Erlang Patterns Matching Business Needs
Torben Hoffmann
 
Using unicode with php
Using unicode with phpUsing unicode with php
Using unicode with php
Elizabeth Smith
 
Static typing vs dynamic typing languages
Static typing vs dynamic typing languagesStatic typing vs dynamic typing languages
Static typing vs dynamic typing languages
Jawad Khan
 
Programming Languages #devcon2013
Programming Languages #devcon2013Programming Languages #devcon2013
Programming Languages #devcon2013
Iván Montes
 
Polyglot Architecture: A Rational Approach to Software Design
Polyglot Architecture: A Rational Approach to Software DesignPolyglot Architecture: A Rational Approach to Software Design
Polyglot Architecture: A Rational Approach to Software Design
kompalg
 
Static vs dynamic types
Static vs dynamic typesStatic vs dynamic types
Static vs dynamic types
Terence Parr
 

What's hot (10)

Languages formanandmachine
Languages formanandmachineLanguages formanandmachine
Languages formanandmachine
 
NLP techniques for log analysis
NLP techniques for log analysisNLP techniques for log analysis
NLP techniques for log analysis
 
Python Intro For Managers
Python Intro For ManagersPython Intro For Managers
Python Intro For Managers
 
Php
PhpPhp
Php
 
NDC London 2014: Erlang Patterns Matching Business Needs
NDC London 2014: Erlang Patterns Matching Business NeedsNDC London 2014: Erlang Patterns Matching Business Needs
NDC London 2014: Erlang Patterns Matching Business Needs
 
Using unicode with php
Using unicode with phpUsing unicode with php
Using unicode with php
 
Static typing vs dynamic typing languages
Static typing vs dynamic typing languagesStatic typing vs dynamic typing languages
Static typing vs dynamic typing languages
 
Programming Languages #devcon2013
Programming Languages #devcon2013Programming Languages #devcon2013
Programming Languages #devcon2013
 
Polyglot Architecture: A Rational Approach to Software Design
Polyglot Architecture: A Rational Approach to Software DesignPolyglot Architecture: A Rational Approach to Software Design
Polyglot Architecture: A Rational Approach to Software Design
 
Static vs dynamic types
Static vs dynamic typesStatic vs dynamic types
Static vs dynamic types
 

Similar to Unknown features of PHP

State of Crypto in Python
State of Crypto in PythonState of Crypto in Python
State of Crypto in Python
jarito030506
 
haXe - One codebase to rule'em all
haXe - One codebase to rule'em allhaXe - One codebase to rule'em all
haXe - One codebase to rule'em all
Tom Crombez
 
Api crash
Api crashApi crash
Api crash
Tony Nguyen
 
Api crash
Api crashApi crash
Api crash
Hoang Nguyen
 
Api crash
Api crashApi crash
Api crash
Fraboni Ec
 
Api crash
Api crashApi crash
Api crash
James Wong
 
Api crash
Api crashApi crash
Api crash
Luis Goldster
 
Api crash
Api crashApi crash
Api crash
Harry Potter
 
Api crash
Api crashApi crash
Api crash
Young Alista
 
State of Crypto in Python (OSCON)
State of Crypto in Python (OSCON)State of Crypto in Python (OSCON)
State of Crypto in Python (OSCON)
jarito030506
 
The ES6 Conundrum - All Things Open 2015
The ES6 Conundrum - All Things Open 2015The ES6 Conundrum - All Things Open 2015
The ES6 Conundrum - All Things Open 2015
Christian Heilmann
 
Interoperable PHP
Interoperable PHPInteroperable PHP
Interoperable PHP
weltling
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python Programming
Akhil Kaushik
 
Putting Compilers to Work
Putting Compilers to WorkPutting Compilers to Work
Putting Compilers to Work
SingleStore
 
Smart Signatures—Experiments in Authentication (Stanford BPASE 2018 final)
Smart Signatures—Experiments in Authentication (Stanford BPASE 2018 final)Smart Signatures—Experiments in Authentication (Stanford BPASE 2018 final)
Smart Signatures—Experiments in Authentication (Stanford BPASE 2018 final)
Christopher Allen
 
Hack language
Hack languageHack language
Hack language
Ravindra Bhadane
 
Php internal architecture
Php internal architecturePhp internal architecture
Php internal architecture
Elizabeth Smith
 
Intro to Perfect - LA presentation
Intro to Perfect - LA presentationIntro to Perfect - LA presentation
Intro to Perfect - LA presentation
Tim Taplin
 
Secure PHP Coding
Secure PHP CodingSecure PHP Coding
Secure PHP Coding
Narudom Roongsiriwong, CISSP
 
Rooting Your Internals: Inter-Protocol Exploitation, custom shellcode and BeEF
 Rooting Your Internals: Inter-Protocol Exploitation, custom shellcode and BeEF Rooting Your Internals: Inter-Protocol Exploitation, custom shellcode and BeEF
Rooting Your Internals: Inter-Protocol Exploitation, custom shellcode and BeEF
Michele Orru
 

Similar to Unknown features of PHP (20)

State of Crypto in Python
State of Crypto in PythonState of Crypto in Python
State of Crypto in Python
 
haXe - One codebase to rule'em all
haXe - One codebase to rule'em allhaXe - One codebase to rule'em all
haXe - One codebase to rule'em all
 
Api crash
Api crashApi crash
Api crash
 
Api crash
Api crashApi crash
Api crash
 
Api crash
Api crashApi crash
Api crash
 
Api crash
Api crashApi crash
Api crash
 
Api crash
Api crashApi crash
Api crash
 
Api crash
Api crashApi crash
Api crash
 
Api crash
Api crashApi crash
Api crash
 
State of Crypto in Python (OSCON)
State of Crypto in Python (OSCON)State of Crypto in Python (OSCON)
State of Crypto in Python (OSCON)
 
The ES6 Conundrum - All Things Open 2015
The ES6 Conundrum - All Things Open 2015The ES6 Conundrum - All Things Open 2015
The ES6 Conundrum - All Things Open 2015
 
Interoperable PHP
Interoperable PHPInteroperable PHP
Interoperable PHP
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python Programming
 
Putting Compilers to Work
Putting Compilers to WorkPutting Compilers to Work
Putting Compilers to Work
 
Smart Signatures—Experiments in Authentication (Stanford BPASE 2018 final)
Smart Signatures—Experiments in Authentication (Stanford BPASE 2018 final)Smart Signatures—Experiments in Authentication (Stanford BPASE 2018 final)
Smart Signatures—Experiments in Authentication (Stanford BPASE 2018 final)
 
Hack language
Hack languageHack language
Hack language
 
Php internal architecture
Php internal architecturePhp internal architecture
Php internal architecture
 
Intro to Perfect - LA presentation
Intro to Perfect - LA presentationIntro to Perfect - LA presentation
Intro to Perfect - LA presentation
 
Secure PHP Coding
Secure PHP CodingSecure PHP Coding
Secure PHP Coding
 
Rooting Your Internals: Inter-Protocol Exploitation, custom shellcode and BeEF
 Rooting Your Internals: Inter-Protocol Exploitation, custom shellcode and BeEF Rooting Your Internals: Inter-Protocol Exploitation, custom shellcode and BeEF
Rooting Your Internals: Inter-Protocol Exploitation, custom shellcode and BeEF
 

Recently uploaded

办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
xjq03c34
 
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
APNIC
 
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
thezot
 
HijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process HollowingHijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process Hollowing
Donato Onofri
 
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
rtunex8r
 
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
3a0sd7z3
 
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
APNIC
 
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
3a0sd7z3
 
Discover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to IndiaDiscover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to India
davidjhones387
 
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
k4ncd0z
 
Bengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal BrandingBengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal Branding
Tarandeep Singh
 
Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?
Paul Walk
 

Recently uploaded (12)

办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
 
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
 
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
 
HijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process HollowingHijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process Hollowing
 
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
 
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
 
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
 
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
 
Discover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to IndiaDiscover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to India
 
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
 
Bengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal BrandingBengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal Branding
 
Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?
 

Unknown features of PHP