PHP-CPP는 C 11으로 작성되었습니다. 따라서 Ubuntu 12.04 LTS에 설치된 G의 이전 버전은 지원하지 않습니다. G 컴파일러를 위의 버전 4.8.x로 업그레이드해야합니다. 업그레이드를 수행하는 단계를 자세히 설명하는 기사가 있습니다. 그곳에 나열된 지침을 따르십시오.
또한 PHP-CPP 컴파일은 php.h 헤더 파일을 사용합니다. PHP-DEV가 설치되지 않는 한이 파일은 일반적으로 우분투 상자에 누락됩니다. 이 명령을 발행하여 PHP5 관련 개발 파일을 설치할 수 있습니다.
<span>sudo apt-get install php5-dev</span>
PHP-CPP는 다음 3 개의 파일을 포함하는 스켈레톤 확장 프로젝트를 제공합니다.
<span>make && sudo make install</span>
<span>sudo apt-get install php5-dev</span>
main.cpp
<span>make && sudo make install</span>
<span>extension=skeleton.so</span>
이 경우 두 번째 서명을 사용하고 있으며 매개 변수는 배열 양식 (PHP 기능)의 값으로 전달됩니다.
<span><span>#include <phpcpp.h></span> </span> <span>/** </span><span> * tell the compiler that the get_module is a pure C function </span><span> */ </span><span>extern "C" { </span> <span>/** </span><span> * Function that is called by PHP right after the PHP process </span><span> * has started, and that returns an address of an internal PHP </span><span> * strucure with all the details and features of your extension </span><span> * </span><span> * @return void* a pointer to an address that is understood by PHP </span><span> */ </span> PHPCPP_EXPORT <span>void *get_module() </span> <span>{ </span> <span>// static(!) Php::Extension object that should stay in memory </span> <span>// for the entire duration of the process (that's why it's static) </span> <span>static Php::Extension extension("yourextension", "1.0"); </span> <span>// @todo add your own functions, classes, namespaces to the extension </span> <span>// return the extension </span> <span>return extension; </span> <span>} </span><span>} </span>
<span>static Php::Extension extension("skeleton", "1.0"); // To be humble, we can change the version number to 0.0.1</span>
위 내용은 PHP-CPP를 통해 PHP 확장 개발을 시작합니다의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!