在PHP中,private
和protected
方法之间似乎没有很大的差异.
我问为什么我应该protected
在PHP Chatroom中使用并得到这个答案:
除非你有充分的理由不这样做:是的,
而且很好的理由是,如果你的代码是闭源库
,即便如此,它也可以用反射覆盖
所以 -
如果private
方法可能被Reflection重写,那么方法中的重点是什么private
?
我想替换这段代码:
$html=<<<EOF
<p>{${$var[i]}[name]}</p>
<p>{${$var[i+1]}[name]}</p>
<p>{${$var[i+2]}[name]}</p>
<p>{${$var[i+3]}[name]}</p>
EOF;
Run Code Online (Sandbox Code Playgroud)
用这样的东西:
$html=<<<EOF
<p>{${$var[new_i]}[name]}</p>
<p>{${$var[new_i]}[name]}</p>
<p>{${$var[new_i]}[name]}</p>
<p>{${$var[new_i]}[name]}</p>
EOF;
Run Code Online (Sandbox Code Playgroud)
并保留第一段代码的功能.
有可能吗?
我在php编码.我尝试调试以查看值是否为null.
这是我的代码:
echo if (isset($_Post[porduct]));
Run Code Online (Sandbox Code Playgroud)
它不起作用,有谁知道为什么?
我对我在代码中做错了什么感到有些困惑
function submitArticle() {
var postTitle = encodeURIComponent(document.getElementById('postTitle').value);
var postDes = encodeURIComponent(document.getElementById('postDes').value);
var postCont = encodeURIComponent(document.getElementById('postCont').value);
var data = "postTitle=" + postTitle + "&postDes=" + postDes + "&postCont=" + postDes;
var getXML = function () {
try {
xhr = new XMLHttpRequest();
}
catch(e) {
try {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e) {
alert("Your Browser is not Supported");
}
}
}
}
open('POST', 'http://localhost/blog/engine/engine.php', true);
setRequestHeader("Content-type", "application/x-www-form-urlencoded");
send(data);
getXML.onreadystatechange = …
Run Code Online (Sandbox Code Playgroud) 我在 Python 3.5 中产生了这个错误:
回溯(最近一次调用):文件“C:\Users\Owner\AppData\Local\Programs\Python\Python35\lib\shelve.py”,第 111 行,在 __getitem__ value = self.cache[key] KeyError: ' P4_蔬菜'
在处理上述异常的过程中,又发生了一个异常:
回溯(最近一次调用):文件“C:\Users\Owner\Documents\Python\Allotment\allotment.py”,第 217 行,在 main_program() 文件“C:\Users\Owner\Documents\Python\Allotment\ allotment.py", line 195, in main_program main_program() 文件 "C:\Users\Owner\Documents\Python\Allotment\allotment.py", line 49, in main_program print("Plot 4 - ", s["P4_vegetables "]) 文件 "C:\Users\Owner\AppData\Local\Programs\Python\Python35\lib\shelve.py",第 113 行,在 __getitem__ f = BytesIO(self.dict[key.encode(self.keyencoding) ]) 文件“C:\Users\Owner\AppData\Local\Programs\Python\Python35\lib\dbm\dumb.py”,第 141 行,在 __getitem__ pos, siz = self._index[key] # 可能会引发 KeyError KeyError : b'P4_vegetables'
我有一个字符串,最多可包含2000个字符.我只想显示前40个单词.
字符串是$row['content']
.我怎么只显示前50?
谢谢.