我曾经听说过一个包含所有应用程序常量的类是很好的,这样你只有一个包含所有常量的位置.
我试过这样做:
class constants{
define("EH_MAILER",1);
}
Run Code Online (Sandbox Code Playgroud)
和
class constants{
const EH_MAILER =1;
}
Run Code Online (Sandbox Code Playgroud)
但这两种方式都不起作用.有什么建议?
这个问题是我今天关于cookie的各种问题的结果.
如您所知,使用cookie处理登录过程并不节省.
但是,如何在登录时设置cookie并在重新启动浏览器时自动登录?
如果我根据cookie的存在重定向,这是危险的,因为其他人可以创建一个cookie.那么解决这个问题的方法是什么?
幸运的是,我知道如何从数据库中获取数据,这不是问题.对于面向对象的应用程序,我会有一个用户/人员的表.我也有一person节课.
案例: 我想向最终用户展示一份包含所有人的清单.这样做的正确方法是什么?
mysql_fetch_object()在这种情况下使用php将创建它自己的对象类型,而不是我自己的类型person 或者还有其他更好的方法吗?
你还可以请出示一些(伪)代码吗?
谢谢
我正在使用jquery的popupwindow插件在popupwindow中显示一个表单.提交后如何关闭此窗口? 这是我正在谈论的链接.我可以在pupup窗口中打开一个链接.但提交后我希望它在父窗口中打开.
我怎样才能使它适用于透明的gif和png?
function resizeImage($image,$newImage,$target_width,$target_height, $type="") {
if (is_file($image)) {
if($type == ".gif"){
$image_org=@imagecreatefromgif($image);
}else{
$image_org=@imagecreatefromjpeg($image);
}
if ($image_org) {
list($w,$h,$type,$attr) = getimagesize($image);
$factor=C_Image_Custom::calcRescaleFactor($w,$h,$target_width,$target_height);
if ($factor>1) {
$image_w = $w / $factor;
$image_h = $h / $factor;
} else {
$image_w = $w;
$image_h = $h;
}
//Note: PHP with GD2.0 required for imagecreatetruecolor
$img_copy = imagecreatetruecolor($image_w, $image_h);
imagecopyresampled($img_copy, $image_org, 0, 0, 0, 0, $image_w, $image_h, $w, $h);
if (@imagejpeg($img_copy, $newImage, 80)) {
chmod($newImage,0777);
} else {
echo("<b>Error: </b>Unable to create image …Run Code Online (Sandbox Code Playgroud) 我有一个rss feed的问题.
当我做 <title>This is a title </title>
标题很好地出现在Feed中
但当我ddo $ title ="这是一个倾斜";
<title><![CDATA['$title']]></title>
Run Code Online (Sandbox Code Playgroud)
标题根本没有出现.
它仍然无法正常工作.我动态地生成我的RSS Feed,它看起来像这样:
$item_template="
<item>
<title>[[title]]</title>
<link>[[link]]</link>
<description><![CDATA[[[description]]]]></description>
<pubDate>[[date]]</pubDate>
</item>
";
Run Code Online (Sandbox Code Playgroud)
并在循环中:
$s.=str_replace(
array("[[title]]","[[link]]","[[description]]","[[date]]"),
array(htmlentities($row["title"]),$url,$description,$date),
$item_template);
Run Code Online (Sandbox Code Playgroud)
问题特别是当标题有欧元符号时.然后它出现在我的rss验证器中,如:
Â\x80
Run Code Online (Sandbox Code Playgroud)
更详细的信息:
好的,过去几天我一直在努力,我找不到解决办法.所以我会开始赏金.以下是更多信息:
€<title></title>如果需要更多信息,请询问.
我有下表:
CREATE TABLE `events` (
`evt_id` int(11) NOT NULL AUTO_INCREMENT,
`evt_name` varchar(50) NOT NULL,
`evt_description` varchar(100) DEFAULT NULL,
`evt_startdate` date NOT NULL,
`evt_enddate` date DEFAULT NULL,
`evt_starttime` time DEFAULT NULL,
`evt_endtime` time DEFAULT NULL,
`evt_amtpersons` int(11) DEFAULT NULL,
`sts_id` int(11) NOT NULL,
`adr_id` int(11) DEFAULT NULL,
`evt_amtPersonsSubs` int(11) DEFAULT NULL,
`evt_photo` varchar(50) DEFAULT NULL,
`sys-mut-dt` timestamp NULL DEFAULT NULL,
`sys-mut-user` varchar(20) DEFAULT NULL,
`sys-mut-id` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`evt_id`),
KEY `sts_id` (`sts_id`),
KEY `adr_id` (`adr_id`),
CONSTRAINT `sts_id` …Run Code Online (Sandbox Code Playgroud) PHP Notice: Please no longer include "PHPUnit/Framework.php". in /usr/share/php/PHPUnit/Framework.php on line 50
Fatal error: Class 'PHPUnit_Runner_StandardTestSuiteLoader' not found in /usr/share/php/PHPUnit/TextUI/TestRunner.php on line 434
PHP Fatal error: Class 'PHPUnit_Runner_StandardTestSuiteLoader' not found in /usr/share/php/PHPUnit/TextUI/TestRunner.php on line 434
/var/www/nrka2/build/build.xml:30: exec returned: 255
BUILD FAILED (total time: 2 seconds)
Run Code Online (Sandbox Code Playgroud)
您好我在最新的phpUnit版本中遇到此错误.任何想法如何解决?
在我的TDD项目中,我试图在抽象类中测试一个方法.
abstract class Database_Mapper_Abstract
{
public function setTable($sTablename){
return('foo');
}
}
Run Code Online (Sandbox Code Playgroud)
这是我编写简单测试的方式:
public function testCanSetTable(){
$oMock = $this->getMockForAbstractClass('JCMS_Database_Mapper_Abstract');
$oMock->expects($this->once())
->method('setTable')
->with($this->equalTo('foo'))
->will($this->returnValue('foo'));
$this->assertEquals('foo',$oMock->setTable());
}
Run Code Online (Sandbox Code Playgroud)
当我运行此测试时,我收到以下错误:
Sebastian Bergmann的PHPUnit 3.5.13.
Ë
时间:1秒,内存:6.75Mb
有1个错误:
1)Database_Mapper_AbstractTest :: testCanSetTable缺少Database_Mapper_Abstract :: setTable()的参数1,在第15行的K:\ xampp\htdocs\tests\library\Database\Mapper\Abstract.php中调用并定义
K:\ xampp\htdocs\library\Database\Mapper\Abstract.php:4 K:\ xampp\htdocs\tests\library\Database\Mapper\Abstract.php:15
FAILURES!测试:1,断言:0,错误:1.
我理解这一点的方法是它无法找到setTable函数的参数.但我用这个with()方法设置它.我也试过了with('foo').这对我也没有帮助.
有没有人有想法?
我想在使用doctrine模式工具创建的数据库中保存日期时间.在我的表单中,我设置了日期和时间,我想将其保存为数据库中的日期时间.
所以我试过这个:
$e->setStartDateTime(new Zend_Date('2011-09-01T22:00:00',Zend_date::DATETIME));
但我得到错误:
PHP Fatal error: Call to undefined method Zend_Date::format() in /var/www/shared/Doctrine/lib/vendor/doctrine-dbal/lib/Doctrine/DBAL/Types/DateTimeType.php on line 44
Run Code Online (Sandbox Code Playgroud)
有没有人有这方面的经验,能够帮助我解决这个问题?
php ×7
oop ×2
phpunit ×2
sql ×2
unit-testing ×2
ant ×1
constants ×1
cookies ×1
doctrine-orm ×1
gd ×1
gif ×1
jquery ×1
mysql ×1
namespaces ×1
popupwindow ×1
rss ×1
session ×1
transparency ×1
zend-date ×1