- Notifications
You must be signed in to change notification settings - Fork1
symisc/PH7 split into original source files for better readability and maintainability
License
lhsazevedo/ph7
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Fork ofPH7, split into original source files for better readability and maintainability.
Note
This project is for educational purposes and to provide an accessible version of the PH7 source code, and may not be suitable for production use.
PH7 is a fast, embeddable PHP engine written in C, supporting PHP 5.3 features and extensive built-in functionality.
- Embeddable: Integrate PHP into C/C++ applications.
- PHP 5.3 Support: Includes modern PHP constructs and syntax.
- Thread-Safe: ANSI C compliant, suitable for various platforms.
- Rich Functionality: Over 470 built-in functions.
For more details, visit the originalPH7 repository.
The provided Makefile builds the PH7 executable by default, including math functions.
To build the executable:
make
To build the executable without math functions:
make PH7_ENABLE_MATH_FUNC=0
After building, you can run the PH7 executable with any PHP script. Here is an example using a test script:
./build/ph7 script/hello_world.php# Hello World from PH7
Thescript
directory contains over 70 PHP test scripts. You can run these scripts using the PH7 executable to see various features and functionality in action.
If you need to integrate PH7 into your C/C++ applications, you can use the PH7 library.
To build the PH7 static library:
make lib
The static librarylibph7.a
will be created in thebuild
directory.
Here is an example of using the PH7 library in a C program:
// ph7_test.c#include<stdio.h>#include"ph7.h"#definePHP_PROG "<?php echo 'Hello World'; ?>"staticintoutput_consumer(constvoid*output,unsignedintlen,void*data) {printf("%.*s",len, (constchar*)output);returnPH7_OK;}intmain(void) {ph7*engine;ph7_vm*vm;ph7_init(&engine);ph7_compile_v2(engine,PHP_PROG,-1,&vm,0);ph7_vm_config(vm,PH7_VM_CONFIG_OUTPUT,output_consumer,0);ph7_vm_exec(vm,0);ph7_vm_release(vm);ph7_release(engine);return0;}
Compile with:
gcc -o ph7_test ph7_test.c -Iinclude -Lbuild -lph7
And run:
./ph7_test# Hello World
See theexamples
directory for more usage examples.
Fork, improve, and submit pull requests. Contributions are welcome!