小编San*_*ath的帖子

PHP sprintf逃避%

我想要以下输出: -

即将从您的充值帐户中扣除50%的27.59欧元.

当我做这样的事情: -

$variablesArray[0] = '€';
$variablesArray[1] = 27.59;
$stringWithVariables = 'About to deduct 50% of %s %s from your Top-Up account.';
echo vsprintf($stringWithVariables, $variablesArray);
Run Code Online (Sandbox Code Playgroud)

但它给了我这个错误vsprintf() [function.vsprintf]: Too few arguments in ...,因为它认为%50%还进行更换.我怎么逃避它?

php printf escaping

167
推荐指数
3
解决办法
7万
查看次数

urlencoded正斜杠正在破坏URL

关于系统

我的项目中有这种格式的URL: -

http://project_name/browse_by_exam/type/tutor_search/keyword/class/new_search/1/search_exam/0/search_subject/0
Run Code Online (Sandbox Code Playgroud)

其中关键字/类对意味着使用"class"关键字进行搜索.

我有一个常见的index.php文件,它为项目中的每个模块执行.只有一个重写规则可以从URL中删除index.php: -

RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L,QSA]
Run Code Online (Sandbox Code Playgroud)

我在阅读搜索URL时准备搜索URL和urldecode()时使用urlencode().

问题

只有正斜杠字符会破坏导致404页面未找到错误的URL.例如,如果我搜索one/twoURL是

http://project_name/browse_by_exam/type/tutor_search/keyword/one%2Ftwo/new_search/1/search_exam/0/search_subject/0/page_sort/
Run Code Online (Sandbox Code Playgroud)

我该如何解决?我需要将index.php隐藏在URL中.否则,如果不需要,那么正斜杠就没有问题了,我可以使用这个URL: -

http://project_name/index.php?browse_by_exam/type/tutor_search/keyword/one
%2Ftwo/new_search/1/search_exam/0/search_subject/0
Run Code Online (Sandbox Code Playgroud)

.htaccess url-rewriting url-encoding http-status-code-404

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

如何在非MAC OS上解决npm install throw fsevents警告?

以下警告被npm install命令 -

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules\rea
ct-scripts\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@
1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}
)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\ch
okidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@
1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}
)
Run Code Online (Sandbox Code Playgroud)

警告显然导致我们的詹金斯工作标记失败,所以我们只是试图摆脱相同.

我已经检查了这个/sf/answers/3005687891/ 但是,与那里提到的不同,我的设置中没有任何/ node_modules/fserrors.另外,我的package.json不包含fserrors.以下是我的package.json -

{
  "name": "mvc-panel",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "bootstrap": "^3.3.7",
    "jquery": "^3.2.1",
    "material-ui": "^0.18.3",
    "qs": "^6.4.0",
    "react": "^15.5.4", …
Run Code Online (Sandbox Code Playgroud)

fsevents node.js jenkins npm-install

51
推荐指数
7
解决办法
8万
查看次数

如何使用类方法作为回调函数?

如果我array_walk在类函数内部使用同一个类的另一个函数

class user
{
   public function getUserFields($userIdsArray,$fieldsArray)
   {

     if((isNonEmptyArray($userIdsArray)) && (isNonEmptyArray($fieldsArray)))
     {
         array_walk($fieldsArray, 'test_print');
     }
   }


  private function test_print($item, $key)
  {
         //replace the $item if it matches something
  }

}
Run Code Online (Sandbox Code Playgroud)

它给我以下错误 -

警告: array_walk()[function.array-walk]:无法调用 test_print()- 函数不存在于......

那么,我$this->test_print()在使用时如何指定array_walk()

php oop callback array-walk

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

通过AJAX发布的布尔变量在服务器端被视为字符串

以下是向会话购物车添加类和包的AJAX功能的一部分: -

jquery部分

function addClassToCart(itemId)
{
   addItemToCart(itemId,true);
}

function addPackToCart(itemId)
{
   addItemToCart(itemId,false);
}

function addItemToCart(itemId,isClass)
{   
     $.post(url+"/ajax/add_cart", { operation: 'add_cart','isClass':isClass, 'itemId': itemId},
        function(data)
        {
               if(data.success)
               {
                      alert("item added to cart");
               }
        }, "json");

}
Run Code Online (Sandbox Code Playgroud)

AJAX请求处理php部分 -

//Checking operation and other posted parameters
if($_POST['isClass'])
{
  //Code to add class to session cart

}
else
{
  //Code to add pack to session cart
}
Run Code Online (Sandbox Code Playgroud)

奇怪的是

无论我是否传递true/false(通过调用addClassToCart()和addPackToCart()),总是会向会话购物车添加类的代码执行.
如果我把echo语句放在那里: -

    if($_POST['isClass'])
    {
      echo "see if condition ".$_POST['isClass'];
    }
    else
    {
      echo "see else condition …
Run Code Online (Sandbox Code Playgroud)

php ajax jquery boolean post-processing

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

在MySQL中的SELECT查询中使用LIKE进行SWITCH

我有这个标签表

CREATE TABLE IF NOT EXISTS `Tags` (
   `id_tag` int(10) unsigned NOT NULL auto_increment,
   `tag` varchar(255) default NULL,
   PRIMARY KEY  (`id_tag`),
   UNIQUE KEY `tag` (`tag`),
   KEY `id_tag` (`id_tag`),
   KEY `tag_2` (`tag`),
   KEY `tag_3` (`tag`),
   KEY `tag_4` (`tag`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2937 ;

INSERT INTO `Tags` (`id_tag`, `tag`) VALUES
   (1816, '(class'),
   (2642, 'class\r\n\r\nâ?¬35'),
   (1906, 'class\r\nif'),
   (1398, 'class'),
   (2436, 'class)'),
   (1973, 'class:\n1.'),
   (2791, 'classes'),
   (1325, 'New'),
   (2185, 'pack'),
   (1905, 'packed'),
   (1389, 'WebClass');
Run Code Online (Sandbox Code Playgroud)

我想取其中标签匹配关键字的所有记录classpacknew与这表明该3个关键字的实际与标记字段匹配的另一场一起.

以下查询未提供正确的结果查询1

select …
Run Code Online (Sandbox Code Playgroud)

mysql sql case switch-statement sql-like

27
推荐指数
2
解决办法
6万
查看次数

jquery选择器,用于获取所选的特定值的所有选择下拉列表

如何使用jQuery选择器选择所有选择框,其中选择的值为"A1"?

样品选择框:

<select name="accesslevel">
<option value="A1">A1 Access</option>
<option value="A2">A2 Access</option>
</select>
Run Code Online (Sandbox Code Playgroud)

我必须使用选择器来执行以下操作:

.parent().nextAll('td[id^="A1Access"]').show();
.parent().nextAll('td[id^="A2Access"]').hide();
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?

html jquery jquery-selectors

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

jquery选择器:ID以某些东西开头(关键字"section")

我想定位所有id以"section"开头的div; 对于每个这些div,我想显示以"pre"开头的类型输入的子div.

    //groups = $('div [id^=section]');  
    groups = $('[id^=section]');    

    $.each(groups, function(key, group) {
         alert(key + ': ' + group); 
        //inputs = group.('[id^=pre]'); 
    });


<div id="section-A1">       
    <input id="preBeginDtl" name="BeginDtlFields" value="" type="hidden">
    <input id="other" name="name2" value="" type="input">
    <input id="preGroup" name="GRP" value="AA" type="hidden">
</div>
Run Code Online (Sandbox Code Playgroud)

jquery css-selectors

18
推荐指数
3
解决办法
5万
查看次数

如何从phing目标返回值?

我希望有一个像这样的foreach任务,它迭代目录"A"中的所有文件/目录 -

<foreach param="dirname" absparam="absname" target="subtask">
  <fileset dir="${dir.destination}/${dir.subdir}/">
    <type type="file" />
    </fileset>
</foreach>
Run Code Online (Sandbox Code Playgroud)

目标"子任务"应该检查文件/文件夹的对应物是否存在于另一个目录"B"中(我基本上比较目录A和B),如果不是,则返回以下任一项 -

  • 一只旗.
  • 文件名.

以下是一些参考代码 -

<target name="subtask">
    <if>
        <filesmatch file1="${file1}" file2="${file2}"/>
        <then>
            Return false. But how?
        </then>
        <else>
            Return true of name of the file. How?
        </else>
    </if>
</target>
Run Code Online (Sandbox Code Playgroud)

注意 - 如果可以在不调用目标的情况下完成此操作,则可以.我不确定逻辑是否适合在foreachtask本身.在phing文档中找不到任何这样的东西.

基本上,我应该在循环结束时获得目录B中不存在的文件名列表.

你也可以阅读我的这个问题,如果你能给出一些指示以某种方式解决问题.

更新

重述这个问题,因为我觉得问题描述不清楚.该phing文件说,一个目标没有返回值-

目标是在项目中分配了唯一名称的项目组件(但不是其他目标)的集合.目标通常执行特定任务 - 或调用执行特定任务的其他目标 - 因此目标有点像函数(但目标没有返回值).

我不明白它为什么这么设计.有了这个赏金,我想知道除了必须在PHP中定义自己的自定义任务,然后设置属性之外是否还有一些解决方法 -

$this->getProject()->setNewProperty('modifiedElements', implode("\n\n",$modifiedElementsArray));
Run Code Online (Sandbox Code Playgroud)

可以在构建文件中访问

我有一个目标,检查我的生产代码库是否与预期的git版本有任何差异 -

<target name="compare_prod_with_expected_revision">
        <input propertyname="box.git_version">
            Enter git version of the production …
Run Code Online (Sandbox Code Playgroud)

phing

13
推荐指数
1
解决办法
827
查看次数

编译错误包com.fasterxml.jackson.annotation不存在

以下课程显示问题 - 无法解决导入 com.fasterxml.jackson -

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;


@JsonIgnoreProperties(ignoreUnknown=true)
public class MerchantDetailsDto {
Run Code Online (Sandbox Code Playgroud)

运行时编译错误clean install-

[ERROR] COMPILATION ERROR : 

[INFO] -------------------------------------------------------------

[ERROR] /Path/to/src/main/java/com/citruspay/common/dto/merchant/MerchantDetailsDto.java:[9,40] package com.fasterxml.jackson.annotation does not exist

[ERROR] /Path/to/src/main/java/com/citruspay/common/dto/merchant/MerchantDetailsDto.java:[11,2] cannot find symbol

  symbol: class JsonIgnoreProperties
Run Code Online (Sandbox Code Playgroud)

pom 定义是这样的,它在一个项目的 pom 中,它被定义为当前项目的依赖项 -

<dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${jackson-core.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>${jackson-core.version}</version>
        </dependency>
Run Code Online (Sandbox Code Playgroud)

<jackson-core.version>2.6.1</jackson-core.version>
Run Code Online (Sandbox Code Playgroud)

我检查了这个组件的 Maven 存储库,它似乎没有任何依赖项。

我尝试将版本更改为最新的 - 2.10.0.pr1 并尝试对依赖项目进行 maven 更新,但找不到在 .m2 中下载的 jar。这个组件对应的目录结构有两个路径——

.m2/fasterxml/jackson/core/jackson-annotations

.m2/repository/com/fasterxml/jackson/core/jackson-annotations

我不确定其中哪一个是实际的,所以我尝试从这两个中删除现有的版本目录,但是当我尝试 maven update 和 clean install 时,甚至没有下载相同版本的 jar。

将不胜感激任何指针。

更新

依赖项目上的干净安装命令的输出 - …

java compiler-errors maven spring-boot

13
推荐指数
1
解决办法
2万
查看次数