我正在扩展一个类,但在某些情况下我会覆盖一个方法.有时在2个参数中,有时在3个,有时没有参数.
不幸的是我收到了PHP警告.
我的最小可验证示例:http: //pastebin.com/6MqUX9Ui
<?php
class first {
public function something($param1) {
return 'first-'.$param1;
}
}
class second extends first {
public function something($param1, $param2) {
return 'second params=('.$param1.','.$param2.')';
}
}
// Strict standards: Declaration of second::something() should be compatible with that of first::something() in /home/szymon/webs/wildcard/www/source/public/override.php on line 13
$myClass = new Second();
var_dump( $myClass->something(123,456) );
Run Code Online (Sandbox Code Playgroud)
我收到PHP错误/警告/信息:
我怎样才能防止这样的错误?
PHP中的isset()函数有一些奇怪的问题.让我展示... .
<?php
$aTestArray = array(
'index' => array(
'index' => 'G?ówna'
),
'dodaj' => 'Dodaj og?oszenie',
);
var_dump( isset($aTestArray['index']) );
var_dump( isset($aTestArray['index']['index']) );
var_dump( isset($aTestArray['dodaj']) );
var_dump( isset($aTestArray['index']['none']) );
var_dump( isset($aTestArray['index']['none']['none2']) );
// This unexpectedly returns TRUE
var_dump( isset($aTestArray['dodaj']['none']) );
var_dump( isset($aTestArray['dodaj']['none']['none2']) );
?>
Run Code Online (Sandbox Code Playgroud)
var_dump将返回:
bool(true)
bool(true)
bool(true)
bool(false)
bool(false)
bool(true)
bool(false)
Run Code Online (Sandbox Code Playgroud)
为什么第六个var_dump()返回TRUE?
我有一个Window1.xaml主窗口; 在一些事件之后,我显示一个UserControl EditFile.xaml.
背后的代码是:
public static int whichSelected = -1;
private void button1_Click(object sender, RoutedEventArgs e)
{
//searchEditPanel.Children.Clear();
whichSelected = listViewFiles.SelectedIndex;
searchEditPanel.Children.Add(_EditFileControle); //this is Grid
}
Run Code Online (Sandbox Code Playgroud)
现在,如何通过单击"取消"按钮或类似内容来关闭打开/添加的UserControl?