NewContext creates a new execution context for the active engine and returns an error if the execution context failed to initialize at any point. This corresponds to PHP's RINIT (request init) phase.
()
| 59 | // an error if the execution context failed to initialize at any point. This |
| 60 | // corresponds to PHP's RINIT (request init) phase. |
| 61 | func (e *Engine) NewContext() (*Context, error) { |
| 62 | ptr, err := C.context_new() |
| 63 | if err != nil { |
| 64 | return nil, fmt.Errorf("Failed to initialize context for PHP engine") |
| 65 | } |
| 66 | |
| 67 | ctx := &Context{ |
| 68 | Header: make(http.Header), |
| 69 | context: ptr, |
| 70 | values: make([]*Value, 0), |
| 71 | } |
| 72 | |
| 73 | // Store reference to context, using pointer as key. |
| 74 | e.contexts[ptr] = ctx |
| 75 | |
| 76 | return ctx, nil |
| 77 | } |
| 78 | |
| 79 | // Define registers a PHP class for the name passed, using function fn as |
| 80 | // constructor for individual object instances as needed by the PHP context. |
no outgoing calls