Skip to main content

Handle some of the strange standards in PHP projects

Project description

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.php import Php
config = Php.parse_ini_file("config.ini")
print config["sectionName"]["keyName"]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

php-1.1.7.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file php-1.1.7.tar.gz.

File metadata

  • Download URL: php-1.1.7.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for php-1.1.7.tar.gz
Algorithm Hash digest
SHA256 9fb5cc3633d0115d5019190e64855bee5fa20674cbb37fee8bf75d12099eba49
MD5 48ec91d1f805aaf34a3362d76e8df612
BLAKE2b-256 7f4c05bf991400094947d37c76456bf10be2dfaaa6148601969af2f3b90b4bf9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page