Skip to main content

python-php

Making some of those PHP-only functions available to Python

Sometimes you want to write a Python script for a project written in PHP. For the most part, this is easy, but for a few key things, PHP breaks with the standard and does things in a its own way. For these cases, you can use this module to compensate.

Php.http_build_query()

This was ripped shamelessly from a PHP forum and ported to Python:

Essentially, it’s a (hopefully perfect) replica of PHP’s http_build_query() that allows you to pass multi-dimensional arrays to a PHP-managed URL via POST or GET.

Php.parse_ini_file()

A hacked-together attempt at making an .ini file parser that’s compatible with the “standards” that PHP follows in its parse_ini_file() function. Among the handy features included are:

  • List notation (varname[] = value)

  • Associative array notation (varname[key] = value)

  • Removal of wrapping doublequotes (varname = "stuff" becomes varname = stuff)

You can turn off the doublequote removal with stripquotes=False

Example

from php import Php
config = Php.parse_ini_file("config.ini")
print config["sectionName"]["keyName"]

Metadata

Release files for php 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for php 1.2.1
File Size Uploaded
php-1.2.1.tar.gz 4.2 kB Details

Release files / php-1.2.1.tar.gz

Download URL php-1.2.1.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6ab4fb13397a46e3cf0aba5b800884221cafdf636b04a44f19e658a8c9ac6542
BLAKE2b-256 checksum
How to use checksums
50f0b6204711a0b1c60124f52e811cd841488579d116ee8ef81a26e6420a8cf5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

Release history Release notifications | RSS feed

This release

1.2.1 This release

1 release file

1.2.0

1 release file

1.1.7

1 release file

1.1.6

1 release file

1.1.5

1 release file

1.1.4

1 release file

1.1.2

1 release file

1.1

1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page