stesch
stesch

Reputation: 7215

Is there anything like Python's ctype for PHP? Accessing libraries without the need to write an extension?

Python has ctypes to access libraries. In PHP you write extensions for everything. Popular extensions like the one for libgd are available almost everywhere.

Is there any extension which works like Python's ctypes, letting you access libraries without the need to write an PHP extension?

Upvotes: 8

Views: 1863

Answers (5)

stesch
stesch

Reputation: 7215

PHP 7.3 will have FFI (Foreign Function Interface).

Upvotes: 2

user86297
user86297

Reputation: 162

I don't know of any way. But you could let SWIG build an extension for the library you want.

Upvotes: 0

Anthony
Anthony

Reputation: 37065

There is a PHP extension (irony?) called ffi. FFI stands for Foreign Function Interface, which is the generic term for when a language calls libraries written in another language.

Upvotes: 1

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798686

You're looking for ffi.

Upvotes: 2

Pascal MARTIN
Pascal MARTIN

Reputation: 401022

I don't think there is such a thing : in PHP, the "standard" way of using a library is by writting a wrapper arround it, that exports the functions of the library to PHP.

(But maybe an extension could be written to do just what ctypes does ? -- Not sure, but maybe ^^ )

Upvotes: 0

Related Questions