Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

PHPEmbed: revised examples

Summary: these work better with tsphpembed

Reviewed By: shire

Test Plan: just example code, but it runs




git-svn-id: svn+ssh://tubbs/svnroot/projects/phpembed/trunk@65120 2c7ba8d8-a2f7-0310-a573-de162e16dcc7
  • Loading branch information...
commit 4eb2278957ba67a3bb12399e295d400ef5f58880 1 parent 746fe00
boz authored
View
3  examples/Makefile.am
@@ -12,7 +12,8 @@ AM_LDFLAGS = @PHPCONFIGLDFLAGS@
# List of libraries to link with.
LDADD = @PHPCONFIGLIBS@ $(top_builddir)/src/libphpembed.la -lphp5
-bin_PROGRAMS = test usage
+bin_PROGRAMS = test usage example
test_SOURCES = test.cpp
usage_SOURCES = usage.cpp
+example_SOURCES = example.cpp
View
6 examples/example.cpp
@@ -10,7 +10,7 @@ void print_php_array(php_array &a, int depth = 0);
// define our own output functions with this exact signature
void print_null(const char *str) {}
void print_mine(const char *str){
- printf("My Output: %s", str);
+ printf("%s", str);
}
int main(int argc, char **argv){
@@ -30,7 +30,9 @@ int main(int argc, char **argv){
// an example of calling into a function with C arguments
long tre = 3;
- printf("%s\n", p.call_c_string("trivial_func", "sld", "answer: ", tre, 4.5));
+ char *tres = p.call_c_string("trivial_func", "sld", "answer: ", tre, 4.5);
+ if(tres)
+ printf("%s\n", tres);
printf("\n");
// this test function returns a string, but we call_long so it converts it
View
8 examples/usage.cpp
@@ -6,7 +6,7 @@
// define our own output functions with this exact signature
void print_null(const char *str) {}
-void print_mine(const char *str){ printf("My Output: %s", str); }
+void print_mine(const char *str){ printf("%s", str); }
int main(int argc, char **argv){
@@ -17,12 +17,6 @@ int main(int argc, char **argv){
p.set_message_function(print_null);
p.set_output_function(print_mine);
- // Load a php file
- if(SUCCESS != p.load("usage.php")){
- printf("load failed\n");
- exit(1);
- }
-
long memused = p.call_long("memory_get_usage");
hash_set<string> ex;
ex = p.call_string_hash_set("get_loaded_extensions");
View
12 examples/usage.php
@@ -1,12 +0,0 @@
-<?
-
-// usage.php - tutorial file
-// Copyright (c) 2007 Andrew Bosworth, Facebook, inc
-// All rights reserved
-//
-// This file is loaded by the PHP interpreter compiled into usage
-
-// we set a larger memory limit just in case
-ini_set('memory_limit', '100M');
-
-?>
Please sign in to comment.
Something went wrong with that request. Please try again.