草庐IT

new-config

全部标签

php - Web.config 将所有路径重定向到 index.php - 不工作

我主要使用Apache和.htaccess,但我目前在Windows服务器上托管的网站上工作。Web.config给我带来了很多问题。我正在尝试将所有URL请求重定向到index.php,以便PHP脚本随后可以解析URL并提供正确的页面。.htaccess(在Apache上运行良好)如下:RewriteEngineOnRewriteCond%{REQUEST_FILENAME}-s[OR]RewriteCond%{REQUEST_FILENAME}-l[OR]RewriteCond%{REQUEST_FILENAME}-dRewriteRule^(.*)$-[NC,L]RewriteR

php - 在 Symfony 3.2 中根据 config.yml 使用 TagAwareAdapter?

我知道我可以在Symfony3.2中定义缓存,就像在我的config.yml中那样:cache:default_redis_provider:redis://%redis_password%@%redis_host%:%redis_port%pools:my_redis_cache:adapter:cache.adapter.redispublic:truedefault_lifetime:1200provider:cache.default_redis_provider例如在我的Controller中我可以简单地使用$cache=$this->get('my_redis_cache'

PHP:读取 config.ini 以使用 file() 排列

我的配置文件是这样的:title=myTitle;otherTitle=myOtherTitle;当我用file()读取文件时,它创建了这个数组[0]=>title=myTitle;[1]=>otherTitle=myOtherTitle;我希望数组看起来像[title]=>myTitle;[otherTitle]=>myOtherTitle;我是不是用错了她的方法?我是否应该将整个配置读入一个sting并从那里爆炸? 最佳答案 您可以使用parse_ini_file功能。它在PHP4和5中可用。如果你的配置文件是这样的:one=1

javascript - 未捕获的语法错误 : Invalid or unexpected token for new line

我正在尝试在Javascript函数中打印PHP变量的字符串。每当我在存储在PHP变量中的字符串中使用新行时,在Javascript函数中打印出来时都会出现UncaughtSyntaxError错误. 最佳答案 如果你想跨多行声明一个字符串变量,你可以使用这个语法:varstr=`line1line2line3`;请注意(`)而不是(")/(')双引号或单引号。它们不能用于声明多行字符串。基本上,您需要这样写:jQuery("body").replaceWith(``) 关于javasc

php - 新手 : throw new exception - can we change exception name?

我正在尝试处理异常(exception)情况。所以我有类似的东西:如果发生不好的事情:thrownewCreateContactException($codigo,$result->msg);稍后,我会尝试,如果不行,捕获:try{createContact();}catch(CreateContactException$e){$error.='Anerroroccurredwiththecode:'.$e->getCode().'andmessage:'.$e->getMessage();}1)这行得通吗?我的意思是,这个getCode()和getMessage()与CreateCo

php - Symfony2 : new instance at each service call instead of using the same

我创建了一个服务,但每次调用它时,它都会创建一个新实例,而不是使用同一个实例。这是我的services.yml:my.sessiondata:class:My\Bundle\Service\SessionDatacalls:-[setServices,[@security.context,@service_container,@session,@doctrine.orm.entity_manager]]scope:container还有我的服务:namespaceMy\Bundle\Service;classSessionData{protected$company;publicfun

php - 在构造函数中使用 "new"关键字

我最近读到在构造函数中使用关键字“new”是非常不受欢迎的,但我不确定我是否理解为什么?例如,如何:classA{public$foo;function__construct(){$this->foo=newBar();}}任何不同于:classA{publicfunctionsomeMethod(){$foo=newBar();}}??? 最佳答案 这确实是依赖注入(inject)背后的理论。并不是说使用“new”本身就是个坏主意。相反,通过在您的类内部实例化对象,您正在创建硬依赖关系,如果不更改类本身,这些依赖关系将永远无法更改

php - 在类中加载 config.php

我想在类中加载配置文件。这里是config.php的内容sql.php的内容connect();$result=$this->qry("SELECTuid,nameFFROMuserWHEREemail='".$email."'ANDpassword='".$pwd."'");$row=mysql_fetch_array($result);if(mysql_num_rows($result)>0)returnarray($row[0],$row[1]);elsereturnarray(0,0);}}?>我执行代码使用include('core/sql.php');$obj=newsql

php - window : Add site directory to Apache config

我的计算机上有一个Apache的本地实例用于开发目的,我正在尝试将站点目录添加到Apache的httpconf文件,其中包含一些我正在尝试使用Eclipse调试的示例Web应用程序。我要添加的目录如下:C:\Eclipse_Workspace\dummyWeb添加路径后,我重新启动了Apache并尝试输入一个URL为:http://localhost/Eclipse_Workspace/dummyWeb/enterGreeting.php但我收到404错误页面。我不确定我必须做什么才能让页面正常打开。我是Apache服务器配置的新手,正在使用ApacheConfLite作为基于GUI的

php - 为什么用 Zend_Config 对象加载 Zend_Application 会产生与发送文件名不同的结果?

我似乎遇到了一个问题,即使用Zend_Config对象加载Zend_Application对象产生的结果与使用文件名加载Zend_Application对象产生的结果不同。为了说明我的观点,我有以下两种加载方法,第一种有效(请注意,此时也定义了所有常量:/**Zend_Application*/require_once'Zend/Application.php';//Createapplication,bootstrap,andrun$application=newZend_Application(APPLICATION_ENV,APPLICATION_PATH.'/configs/a