MCPcopy Create free account
hub / github.com/php/frankenphp / PHPString

Function PHPString

types.go:49–61  ·  view source on GitHub ↗

EXPERIMENTAL: PHPString converts a Go string to a zend_string with copy. The string can be non-persistent (automatically freed after the request by the ZMM) or persistent. If you choose the second mode, it is your repsonsability to free the allocated memory.

(s string, persistent bool)

Source from the content-addressed store, hash-verified

47// non-persistent (automatically freed after the request by the ZMM) or persistent. If you choose
48// the second mode, it is your repsonsability to free the allocated memory.
49func PHPString(s string, persistent bool) unsafe.Pointer {
50 if s == "" {
51 return nil
52 }
53
54 zendStr := C.zend_string_init(
55 (*C.char)(unsafe.Pointer(unsafe.StringData(s))),
56 C.size_t(len(s)),
57 C._Bool(persistent),
58 )
59
60 return unsafe.Pointer(zendStr)
61}
62
63// AssociativeArray represents a PHP array with ordered key-value pairs
64type AssociativeArray[T any] struct {

Callers 9

TransformMethod · 0.92
test_with_constantsFunction · 0.92
GetDataMethod · 0.92
test_uppercaseFunction · 0.92
greetFunction · 0.92
GetNameMethod · 0.92
TestGoStringFunction · 0.85
go_mercure_publishFunction · 0.85
phpValueFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestGoStringFunction · 0.68