Twitters的第2版"Bootstrap"UI框架今天发布.虽然我发现它非常方便,但我不喜欢它是非语义的.
我宁愿避免在我的HTML中设置像.span6 .table-striped这样的类.
由于Bootstrap是建立在较少的基础之上,我期望有一种很好的方法可以使用特定于项目的更少的工作表,可以利用mixins将bootstrap定义的良好归因于漂亮的语义类名.
我将bootstrap.less克隆到myproject.less中,并调整@import行中的路径,然后在底部添加以下内容:
#call-to-action {
.span6;
}
Run Code Online (Sandbox Code Playgroud)
但是Lessc对此嗤之以鼻,抱怨说:
.span6 is undefined in
Run Code Online (Sandbox Code Playgroud)
类似地,尝试.columns(6)会产生相同的错误(".columns is undefined").
其他混合,如.table,.table-bordered等,似乎工作正常.
我错过了什么?使用引导程序的最佳实践是什么,同时将非语义类名称保留在我的语义标记之外?
任何人都知道为什么:
<?PHP
$title = trim($_POST['title']);
$description = trim($_POST['description']);
// Array of allowed image file formats
$allowedExtensions = array('jpeg', 'jpg', 'jfif', 'png', 'gif', 'bmp');
foreach ($_FILES as $file) {
if ($file['tmp_name'] > '') {
if (!in_array(end(explode(".",
strtolower($file['name']))),
$allowedExtensions)) {
echo '<div class="error">Invalid file type.</div>';
}
}
}
if (strlen($title) < 3)
echo '<div class="error">Too short title</div>';
else if (strlen($description) > 70)
echo '<div class="error">Too long desccription.</div>';
else {
move_uploaded_file($_FILES['userfile']['tmp_name'], 'c:\wamp\www\uploads\images/');
}
Run Code Online (Sandbox Code Playgroud)
得到:
警告:move_uploaded_file()[function.move-uploaded-file]:copy()函数的第二个参数不能是第41行的C:\ wamp\www\upload.php中的目录
警告:move_uploaded_file()[function.move-uploaded-file]:无法在C:\ wamp \中将'C:\ wamp\tmp\php1AB.tmp'移动到'c:\ wamp\www\uploads\images /'第41行的www\upload.php
我有一个项目,我处理客户订单.其中一些订单是通过Amazon.com进行的.所以我有一个Order实体,以及一个扩展它的AmazonOrder实体.AmazonOrder添加的一件事是AmazonOrderId.
我需要实现广泛的搜索功能.用户可以在文本框中输入一些内容,并在一个大的where子句中用于一堆表达式.因此,例如,如果用户搜索"111",则结果包括ID为111的任何订单,任何以111开头的邮政编码,任何订单运送到"111 Main St"等. .
这些东西是使用查询生成器创建的查询实现的,该查询具有大orX()表达式.
现在,我想匹配所有订单,但如果它们是AmazonOrder,也匹配AmazonOrderId.
而且我被卡住了 - 我怀疑这可能是不可能的
以下是我构建查询的方法:
$qb->select('o,s')->from('PMS\Entity\Order', 'o');
$qb->leftJoin('o.shippingInfo','s');
$qb->andWhere('o.status = :status');
$qb->setParameter('status',$status);
$qb->andWhere(
$qb->expr()->orX(
$qb->expr()->like('o.id',':query')
$qb->expr()->like('s.address',':query')
$qb->expr()->like('s.city',':query')
)
);
$qb->setParameter('query',$userQuery .'%');
$orders = $qb->getQuery()->getResult();
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚如何添加一个条件,大致上说,"OR(订单是AmazonOrder和AmazonOrderId LIKE'$ userQuery%')"
有人有任何见解吗?要么是处理这个问题的方法,要么是至少确认这样做不可行?
我长期使用基于SQL查询的数据库访问级别.但现在我决定使用ORM Doctrine2.此刻,我对实体工作流程存在一个概念上的误解.
最好通过示例描述:
try {
$user = $entityManager->find('User', 1);
$user->setName('New name');
$entityManager->flush();
}
catch (...)
{
// !we are here: changes failed and $user-row in DB was not updated
}
// ...
$user = $entityManager->find('User', 1);
$user->setOther('Other');
$entityManager->flush(); // <- in this request both [other] and [name] fields will be updated to DB, but only [other] update expected
Run Code Online (Sandbox Code Playgroud)
在第一个代码块中,我获取了$ user对象.更改[名称]并尝试保存,但失败了.在第二个块(与第一个块无关)中,我再次获取了$ user对象.但是ORM第一次返回了与同一对象的链接.所以这个对象已经改变了[name]属性.在第二个块的最后一行,我只想保存[其他]字段,但[other]和[name]都会更新.
解决这种情况的正确方法是什么?
我用
$myblogrepo = $this->_doctrine->getRepository('Entities\Blog')->findBy(array('id' => 12);
Run Code Online (Sandbox Code Playgroud)
我通过访问
foreach($myblogrepo as $key =>$value){
echo $key . $value;
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能获得字段名称?我认为key =>会起作用,但它将键打印为0
所以我认为这会奏效:
foreach($myblogrepo[0] as $key =>$value){
echo $key . $value;
}
Run Code Online (Sandbox Code Playgroud)
但仍然没有..}
我使用以下函数从我的PHP脚本创建固定高度和宽度的缩略图
/*creates thumbnail of required dimensions*/
function createThumbnailofSize($sourcefilepath,$destdir,$reqwidth,$reqheight,$aspectratio=false)
{
/*
* $sourcefilepath = absolute source file path of jpeg
* $destdir = absolute path of destination directory of thumbnail ending with "/"
*/
$thumbWidth = $reqwidth; /*pixels*/
$filename = split("[/\\]",$sourcefilepath);
$filename = $filename[count($filename)-1];
$thumbnail_path = $destdir.$filename;
$image_file = $sourcefilepath;
$img = imagecreatefromjpeg($image_file);
$width = imagesx( $img );
$height = imagesy( $img );
// calculate thumbnail size
$new_width = $thumbWidth;
if($aspectratio==true)
{
$new_height = floor( $height * ( $thumbWidth / $width …Run Code Online (Sandbox Code Playgroud) 我做了各种各样的调试,并参考了很多来源,但我自己也无法解决这个问题.我刚刚开始在PHP中使用OOP而且我正在尝试写一个扑克手牌经销商.我尝试使用递归函数和循环以及if else算法来避免在pokerHand数组中创建重复项.我对这个代码应该如何工作的想法是,当一个新的pokerHand对象被创建时,__construct函数将被自动调用(这是我知道使用构造函数的唯一原因,但我认为还有更多它).然后在do while循环中,代码初始化一个变量$ rand,这是一个介于1和52之间的rand数,并且in_array检查是否已经在数组中输入了"card".如果卡已经发出,__construct函数应该调用自己生成另一张卡,直到新卡出现之后才将其存储在阵列中.
我刚刚开始作为一名程序员,对我的代码的任何反馈对我来说都是无法估量的,我提前感谢你.
<?php
class pokerHand {
private $_pokerHand = array();
private $_counter = 0;
public function __construct (){
do{
if (in_array ($rand = rand(1,52), $this->_pokerHand) ){
return public function __construct();
} else {
$this->_pokerHand[] = $rand;
$this->counter++;
}
} while ($this->_counter < 5)
public function showHand(){
print_r ($this->_pokerHand);
}
}
$obj = new pokerHand();
$obj => showHand();
?>
Run Code Online (Sandbox Code Playgroud)