小编jte*_*rry的帖子

POST变量数组和filter_input

在使用时filter_input,我无法引入POST数组变量.该POST输入:

type              => 'container',
action            => 'edit',
data[display]     => 1,
data[query_limit] => 100
Run Code Online (Sandbox Code Playgroud)

我可以正确地data$_POST超全局访问变量作为数组,但该filter_input函数不返回任何内容:

$data   = $_POST['data']; // Working, woot
$data   = filter_input(INPUT_POST, 'data'); // returns null, should return array
$action = filter_input(INPUT_POST, 'action'); // returns "edit" (correctly)
Run Code Online (Sandbox Code Playgroud)

是不是可以filter_input用于POST数组变量?

php arrays variables post input

47
推荐指数
2
解决办法
3万
查看次数

具有IAM角色的AWS EC2的静态内容

通过阅读//资源如何利用在推出EC2实例临时AWS凭据,我似乎无法得到一个非常简单的POC运行.

期望:

  1. 启动EC2实例
  2. SSH在
  3. 从私有S3存储桶中提取静态内容

脚步:

  1. 创建一个IAM角色
  2. EC2使用IAM指定的上述角色启动新实例; SSH
  3. 使用凭据aws configure和(成功)填充的详细信息设置凭据http://169.254.169.254/latest/meta-data/iam/security-credentials/iam-role-name
  4. 尝试AWS CLI直接使用该文件进行访问

IAM 角色:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "s3:GetObject"
      ],
      "Resource": "arn:aws:s3:::bucket-name/file.png"
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

当我使用它AWS CLI来访问该文件时,抛出此错误:

A client error (Forbidden) occurred when calling the HeadObject operation: Forbidden
Completed 1 part(s) with ... file(s) remaining
Run Code Online (Sandbox Code Playgroud)

我错过了哪一步?

amazon-s3 amazon-ec2 amazon-web-services amazon-iam aws-cli

15
推荐指数
3
解决办法
2万
查看次数

在implode()中使用回调

我有一个多维数组,例如:

$values = array(
    'one' => array(
        'title' => 'Title One',
        'uri'   => 'http://example.com/one',
    ),
    'two' => array(
        'title' => 'Title Two',
        'uri'   => 'http://example.com/two',
    ),
);
Run Code Online (Sandbox Code Playgroud)

...我想通过我的implode函数中的闭包来解析它,àla:

$final_string = implode(' | ', function($values) {
    $return = array();

    foreach($values as $value)
        $return[] = '<a href="' . $value['uri'] . '">' . $value['title'] . '</a>';

    return $return;
});
Run Code Online (Sandbox Code Playgroud)

但是,这种用法会产生Invalid arguments passed错误.我是否缺少哪种语法可以使闭包的使用成为可能?我正在使用PHP v5.3.16.

php closures

11
推荐指数
3
解决办法
6395
查看次数

使用侧边栏菜单时,UITableView 无意中向下移动了约 1 英寸

我的应用程序中有一个奇怪的错误,它使用侧边栏菜单和一个UITableView列表按钮进行导航。当我启动我的应用程序时,一切看起来都很好并且在正确的位置

一旦我对相应的viewController, and navigate back to sidebar menu theUITableView`进行了选择,就会向下移动大约 1 英寸

如果我按下侧边栏菜单按钮将其关闭,菜单会重置并且一切正常且看起来正常。这个错误只发生一次,一旦我选择一行,导航回它,关闭它,UITableView它将处于正确的位置,直到用户重新启动应用程序。知道发生了什么吗?

这是我的侧边栏菜单代码:

#import "SideBarViewController.h"

@interface SideBarViewController ()

@end

@implementation SideBarViewController

@synthesize controllerArray, sidebarButton;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    controllerArray = [NSArray arrayWithObjects:@"Search For Games", @"Login", @"Library", nil];

}

- …
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview ios

5
推荐指数
1
解决办法
2965
查看次数

SASS - 变量参数的默认值

Sass 3.2中添加了变量参数.

@mixin hello($arguments...) {
    property: $arguments;
}

//Usage:
@include hello(1);
@include hello(1, 2, 3);
@include hello(1, 2);
Run Code Online (Sandbox Code Playgroud)

但是,此参数不接受默认值,如此 ($args...: default-value)

现在,我正在使用此代码,但有更好的方法吗?

@mixin transition($values...) {
    $values: null !default;

    @if $values == null {
        $values: all 0.3s ease;
    }

    -webkit-transition: $values;
    -moz-transition: $values;
    -ms-transition: $values;
    -o-transition: $values;
    transition: $values;
}
Run Code Online (Sandbox Code Playgroud)

sass

3
推荐指数
1
解决办法
3271
查看次数