Archived
This forum has been archived. Please start a new discussion on GitHub.
how to pass a value array from c++ to php??
in the example phpdemo.value illustration pass a string use class
but now i want to pass a array ,the elements in the array is not fixed
the elements contain string float int ,,if i use struct in c++,but
php language has no such struct ,how can i do it ????
best regards!!!!
but now i want to pass a array ,the elements in the array is not fixed
the elements contain string float int ,,if i use struct in c++,but
php language has no such struct ,how can i do it ????
best regards!!!!
0
Comments
-
Do you mean from PHP to C++? You cannot do the reverse, as IcePHP has no server side mapping. Passing a struct from PHP to C++ is simple:
// Slice module Demo { struct AStruct { float x; float y; float z; }; interface Foo { void bar(AStruct a); }; };
See the Ice manual for details on how this slice maps to C++ and PHP.0 -
abnormal program terminate
i use function result retrive a class to pass through c++ to php
sequence<string> ArrayZhishu ;
class foo
{
string str;
ArrayZhishu arr;
};
foo func(); //this is the interface define in ice
the function invoke by php ,c++ app run the func and give the value to
php
when i just initilize the foo 's member str;;;
the php get the right value ,it is well
but when i initlize the arr ,,,
m_foo->arr[0]="dgf";
i compile the c++ app is no error
but when i run it
the c++ app crashed
show a error message
Attachment not found.
whether i initilize the sequense manner is wrong???
and how c++ pass a sequence to php as a function result???
best greets!!!0 -
Did you resize the array first? Try:
m_foo->arr.push_back("dgf");
BTW, a struct and a class are not the same thing. struct is much lighter weight and more efficient on the wire. However, it cannot be extended.0