PHP, aka Personal Home Page, is a programming language created in 1995 by Rasmus Lerdorf.
PHP is a server-side scripting language designed primarily for web development but also used as a general-purpose programming language. Originally created by Rasmus Lerdorf in 1994, the PHP reference implementation is now produced by The PHP Development Team. PHP originally stood for Personal Home Page, but it now stands for the recursive acronym PHP: Hypertext Preprocessor. Read more on Wikipedia...
Try now: Riju Β· TIO Β· Replit
#8on PLDB | 27Years Old | 2.4mUsers |
<?php
echo "Hello, world!\n";
<?php
echo 'Hello World';
<?php
// Hello world in PHP
echo 'Hello World!';
?>
#!/usr/bin/php
<?php
echo "PHP\n";
class Person
{
public $firstName;
public $lastName;
public function __construct(string $firstName, string $lastName = '') { // optional second argument
$this->firstName = $firstName;
$this->lastName = $lastName;
}
public function greet(): string {
return 'Hello, my name is ' . $this->firstName .
(($this->lastName != '') ? (' ' . $this->lastName) : '') . '.';
}
public static function staticGreet(string $firstName, string $lastName) {
return 'Hello, my name is ' . $firstName . ' ' . $lastName . '.';
}
}
$he = new Person('John', 'Smith');
$she = new Person('Sally', 'Davis');
$other = new Person('iAmine');
echo $he->greet(); // prints "Hello, my name is John Smith."
echo '<br />';
echo $she->greet(); // prints "Hello, my name is Sally Davis."
echo '<br />';
echo $other->greet(); // prints "Hello, my name is iAmine."
echo '<br />';
echo Person::staticGreet('Jane', 'Doe'); // prints "Hello, my name is Jane Doe."
__CLASS__ __DIR__ __FILE__ __FUNCTION__ __halt_compiler() __LINE__ __METHOD__ __NAMESPACE__ __TRAIT__ abstract and array() as break callable case catch class clone const continue declare default die() do echo else elseif empty() enddeclare endfor endforeach endif endswitch endwhile eval() exit() extends final finally for foreach function global goto if implements include include_once instanceof insteadof interface isset() list() namespace new or print private protected public require require_once return static switch throw trait try unset() use var while xor yield
Feature | Supported | Example | Token |
---|---|---|---|
Conditionals | β | ||
Inheritance | β | ||
Access Modifiers | β | ||
Switch Statements | β | ||
Exceptions | β | ||
Constants | β | ||
Classes | β | ||
While Loops | β | ||
MultiLine Comments | β | /* A comment */ |
/* */ |
Print() Debugging | β | echo | |
Line Comments | β | // A comment |
// |
Increment and decrement operators | β | ||
Functions | β | ||
Variadic Functions | β | function sum(...$nums) { return array_sum($nums); } echo sum(1, 2, 3); // 6 |
|
Traits | β | // The template trait TSingleton { private static $_instance = null; private function __construct(){} // Must have private default constructor and be aware not to open it in the class public static function getInstance() { if (null === self::$_instance) { self::$_instance = new self(); } return self::$_instance; } } class FrontController { use TSingleton; } // Can also be used in already extended classes class WebSite extends SomeClass { use TSingleton; } |
|
Operator Overloading | β | ||
Multiline Strings | β | $xml = << |
|
File Imports | β | ||
Assignment | β | $name = "John" |
|
Constructors | β | ||
Comments | β | ||
Magic Getters and Setters | β | public function __set($name, $value) { echo "Setting '$name' to '$value'\n"; $this->data[$name] = $value; } public function __get($name) { echo "Getting '$name'\n"; if (array_key_exists($name, $this->data)) { return $this->data[$name]; } $trace = debug_backtrace(); trigger_error( 'Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE); return null; } |
|
Strings | β | "hello world" |
' |
Booleans | β | ||
Semantic Indentation | Ο΄ |
repo | stars | description |
---|---|---|
Faker | 21754 | Faker is a PHP library that generates fake data for you |
laravel | 54813 | A PHP framework for web artisans |
framework | 18676 | |
monica | 7726 | Personal CRM. Remember everything about your friends and family. |
mautic | 3421 | Mautic: Open Source Marketing Automation Software. |
SecLists | 19907 | "SecLists is the security tester's companion. It's a collection of multiple types of lists used during security assessments collected in one place. List types include usernames passwords URLs sensitive data patterns fuzzing payloads web shells and many more." |
web-frameworks | 2932 | Which is the fastest web framework? |
monolog | 15663 | "Sends your logs to files sockets inboxes databases and various web services" |
firefly-iii | 2718 | Firefly III: a personal finances manager |
easyswoole | 2336 | "High performance Coroutine PHP Framework base on Swoole" |
PrestaShop | 3922 | PrestaShop offers a fully scalable open source ecommerce solution. |
akaunting | 2097 | Free and Online Accounting Software |
phabricator | 10942 | Open software engineering platform and fun adventure game |
yii2 | 13073 | "Yii 2: The Fast Secure and Professional PHP Framework" |
swoft | 3829 | π PHP Microservice Full Coroutine Framework |
elasticsearch-php | 3510 | Official PHP low-level client for Elasticsearch. |
elementor | 2505 | "The most advanced frontend drag & drop page builder. Create high-end pixel perfect websites at record speeds. Any theme any page any design." |
opencart | 5040 | A free shopping cart system. OpenCart is an open source PHP-based online e-commerce solution. |
jwt-auth | 8258 | π JSON Web Token Authentication for Laravel & Lumen |
cashier | 1655 | |
magento2 | 7806 | "All Submissions you make to Magento Inc. (""Magento"") through GitHub are subject to the following terms and conditions: (1) You grant Magento a perpetual worldwide non-exclusive no charge royalty free irrevocable license under your applicable copyrights and patents to reproduce prepare derivative works of display publically perform subliβ¦" |
webshell | 4829 | This is a webshell open source project |
twill | 1507 | "Twill is an open source CMS toolkit for Laravel that helps developers rapidly create a custom admin console that is intuitive powerful and flexible. Chat with us and others on Spectrum! https://spectrum.chat/twill" |
hyperf | 1186 | "π A coroutine framework that focuses on hyperspeed and flexibility specifically used for build microservices or middlewares." |
composer | 20839 | Dependency Manager for PHP |
title | author | year | reviews | ratings | rating |
---|---|---|---|---|---|
Programming PHP | Rasmus Lerdorf | 2002 | 36 | 642 | 3.92 |
PHP and MySQL Web Development (Developer's Library) | Luke Welling | 2003 | 54 | 854 | 3.95 |
PHP & MySQL For Dummies | Janet Valade | 2002 | 11 | 186 | 3.53 |
Professional PHP Programming | Sascha Schumann | 1999 | 5 | 150 | 3.95 |
Advanced PHP Programming | George Schlossnagle | 2004 | 11 | 116 | 3.86 |