Add Ini() method to change ini values on an engine context#61
Add Ini() method to change ini values on an engine context#61thekid wants to merge 2 commits intodeuill:masterfrom
Conversation
|
Would it make more sense to allow for setting the initial INI values for the engine, since these can not be changed in a per-context basis, and allow callers to set per-context values with plain calls to For example, this code will work fine for any INI values that aren't in this list: package main
import (
"fmt"
"os"
"github.com/deuill/go-php"
)
func setConfig(ctx *php.Context, name, value string) {
ctx.Eval("ini_set('" + name + "', '" + value + "');")
}
func getConfig(ctx *php.Context, name string) string {
val, _ := ctx.Eval("return ini_get('" + name + "');")
defer val.Destroy()
return val.String()
}
func main() {
engine, err := php.New()
if err != nil {
fmt.Printf("could not initialize PHP engine: %s", err)
os.Exit(1)
}
defer engine.Destroy()
context, err := engine.NewContext()
if err != nil {
fmt.Printf("could not initialize PHP context: %s", err)
os.Exit(1)
}
defer context.Destroy()
context.Output = os.Stdout
fmt.Printf("Before: %s\n", getConfig(context, os.Args[1]))
setConfig(context, os.Args[1], os.Args[2])
fmt.Printf("After: %s\n", getConfig(context, os.Args[1]))
}IMO asking users to define functions such as I did some initial work on getting |
Example usage: