DEV Community

Discussion on: Server Side: Dart vs. PHP

Collapse
ljfreelancer88 profile image
Eljay

How about this...

<?php
use Swoole\Http\Server;
use Swoole\Http\Request;
use Swoole\Http\Response;

$server = new Swoole\HTTP\Server("127.0.0.1", 9501);

$server->on("start", function (Server $server) {
    echo "Awesomeness of PHP has been initialized\n";
});

$server->on("request", function (Request $request, Response $response) {
    $response->header("Content-Type", "text/plain");
    $response->end("Hello Philippines!\n");
});

$server->start();
Enter fullscreen mode Exit fullscreen mode