1

Hi i'm tring to write an extension for php in zephir or php-cpp to call my customMethod from my extention when comment block like code below added to php file any suggestion note will be appreciate

<?php 
/* myNotation:my comment */ 
echo "Hello World"
?>

if comment like this added to source when source fired it should be detect that notation myNotation is presented in comment and has value as my comment

here is my sample extension cpp file

 /**
 *  myExtention.cpp
 * 
 */

#include <iostream>
#include <phpcpp.h>

/**
 *  Namespace to use
 */
using namespace std;

/**
 *  HelloWorldEcho()
 *  echo parameter.
 *  @param      &params
 */
void HelloWorldEcho(Php::Parameters &params)
{
    cout << "Your Comment" << params<< endl;
}


// Symbols are exported according to the "C" language
extern "C" 
{
    // export the "get_module" function that will be called by the Zend engine
    PHPCPP_EXPORT void *get_module()
    {
        // create extension
        static Php::Extension extension("myExtention","1.0");

        // add function to extension
        extension.add<HelloWorldEcho>("HelloWorldEcho", {
            Php::ByVal("x", Php::Type::String)
            });

        // return the extension module
        return extension.module();
    }
}

and now when my extension compiled and added to php extensions then i can call it from php file like this

<?php
/**
 *  HelloWorldEcho.php
 * 
 *  An example file to show the working of a php function call in C++.
 */

HelloWorldEcho("my comment");

The main question is that how can i call my extension method call_php_function when i have comment like code below and pass my comment as parameter to my method:

<?php 
/* myNotation:my comment */ 
echo "Hello World"
?>
kenorb
  • 155,785
  • 88
  • 678
  • 743
phpniki
  • 758
  • 4
  • 13

0 Answers0