Module: PHPVM::PHPGlobal

Defined in:
ext/php_vm/php_vm.c

Class Method Summary collapse

Class Method Details

.array(*args) ⇒ Object



877
878
879
880
881
882
883
884
885
886
887
888
# File 'ext/php_vm/php_vm.c', line 877

VALUE rb_php_global_array(int argc, VALUE *argv, VALUE cls)
{
	VALUE result;
	if (argc==1 && TYPE(argv[0])==T_HASH) {
		// hash
		result = argv[0];
	} else {
		// argv
		rb_scan_args(argc, argv, "*", &result);
	}
	return result;
}

.echo(*args) ⇒ Object



841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
# File 'ext/php_vm/php_vm.c', line 841

VALUE rb_php_global_echo(int argc, VALUE *argv, VALUE cls)
{
	int i;

	if (argc==0) {
		rb_raise(rb_eArgError, "Too few arguments");
	}

	// format
	char *format = malloc(argc*2+1);
	for (i=0; i<argc; i++) {
		format[i*2] = '%';
		format[i*2+1] = 's';
	}
	format[i*2] = '\0';

	// argv
	VALUE *argv2 = malloc(sizeof(VALUE)*(argc+1));
	argv2[0] = rb_str_new2(format);
	for (i=0; i<argc; i++) {
		argv2[i+1] = argv[i];
	}
	call_php_method_name_bridge(NULL, NULL, rb_str_new2("printf"), argc+1, argv2);

	// release
	free(format);
	free(argv2);

	return Qnil;
}


872
873
874
875
# File 'ext/php_vm/php_vm.c', line 872

VALUE rb_php_global_print(VALUE cls, VALUE arg)
{
	return rb_php_global_echo(1, &arg, cls);
}

.require(filepath) ⇒ Object



829
830
831
832
833
# File 'ext/php_vm/php_vm.c', line 829

VALUE rb_php_global_require(VALUE cls, VALUE filepath)
{
	php_global_require("require", filepath);
	return Qtrue;
}

.require_once(filepath) ⇒ Object



835
836
837
838
839
# File 'ext/php_vm/php_vm.c', line 835

VALUE rb_php_global_require_once(VALUE cls, VALUE filepath)
{
	php_global_require("require_once", filepath);
	return Qtrue;
}