This is a collection of questions that come up every now and then about syntax in PHP. This is also a Community Wiki, so everyone is invited to participate in maintaining this list.
It used to be hard to find questions about operators and other syntax tokens.¹
The main idea is to have links to existing questions on Stack Overflow, so it's easier for us to reference them, not to copy over content from …
我刚刚开始学习Ruby,我编写了一个生成一些数字的程序,并将它们分配给变量@ one,@ two,@ three等.然后用户可以通过输入它的名称来指定要更改的变量(例如一).然后我需要做'@ [valueofinout] = asd'之类的事情.我怎么会这样做,并且有更好的方式,因为我想的方式似乎被劝阻了?我发现了
x = "myvar"
myvar = "hi"
eval(x) -> "hi"
Run Code Online (Sandbox Code Playgroud)
但我不完全理解为什么需要第二行.在我的情况下,我会使用类似的东西
@one = "21"
input = "one"
input = "@" + input
changeto = "22"
eval(input) -> changeto
Run Code Online (Sandbox Code Playgroud)