Example Php avatar
Example Php

Pricing

Pay per usage

Go to Apify Store
Example Php

Example Php

Example act using PHP as the main language.

Pricing

Pay per usage

Rating

4.7

(4)

Developer

Apify

Apify

Maintained by Apify

Actor stats

3

Bookmarked

54

Total users

0

Monthly active users

a year ago

Last modified

Share

This is simple example how to use PHP in Apify. It uses custom Dockerfile based on php:7.0-cli image.

Dockerfile

FROM php:7.0-cli
COPY ./* ./
CMD [ "php", "./main.php" ]

main.php

<?php
print "Starting ...\n";
print "ENV vars:\n";
print_r($_ENV);
print "Fetching http://example.com ...\n";
$exampleComHtml = file_get_contents('http://example.com');
print "Searching for <h1> tag contents ...\n";
preg_match_all('/<h1>(.*?)<\/h1>/', $exampleComHtml, $matches);
print "Found: " . $matches[1][0] . "\n";
print "I am done!\n";