草庐IT

get_c_string

全部标签

php - 关于继承的 PHP 魔术方法 __get 和 __set

OBS:我直接在这里编码,因为我的代码要复杂得多。如果我编码:classSuperFoo{publicfunction__get($name){return$this->$name;}publicfunction__set($name,$value){$this->$name=$value;}}classFooextendsSuperFoo{private$bar='';}$foo=newFoo();$foo->bar="Whyitdoesn'twork?";var_dump($foo);结果:object(Foo){["bar":"Foo":private]=>string(0)''

PHP - json_encode(string, JSON_UNESCAPED_UNICODE) 不转义捷克字符

我正在从数据库中选择一些数据并将它们编码为json,但我遇到了像这样的捷克符号的问题á,í,ř,č,ž...我的文件是utf-8编码,我的数据库也是utf-8编码,我也将header设置为utf-8编码。请问我还应该做什么?我的代码:header('Content-Type:text/html;charset=utf-8');while($tmprow=mysqli_fetch_array($result)){$row['user']=mb_convert_encoding($tmprow['user'],"UTF-8","auto");$row['package']=mb_conve

php - JSON 架构 : how to allow empty string for property with numeric type?

在属性定义中我需要允许数字或空字符串值,这个表达式是否适合这个目的?"tprice":{"type":["number",{"enum":[""]}]}我用来验证数据的库(Jsv4)为空字符串生成错误:Invalidtype:string当我尝试为此属性设置零长度字符串时。 最佳答案 我认为适合您的解决方案是在架构中使用anyOf。这是适合您的模式:{"$schema":"http://json-schema.org/draft-04/schema#","properties":{"tprice":{"anyOf":[{"type"

php - 如果 URL 是文本文件中的一行,则 file_get_contents 不起作用

嘿,我是PHP新手,所以这可能是一个明显的错误。目前我正在尝试从metacritic读取游戏分数并将其显示给用户。这是我用来执行此操作的代码:$linkToGame='METACRITICLINK';$opts=array('http'=>array('header'=>"User-Agent:MyAgent/1.0\r\n"));$context=stream_context_create($opts);$url=file_get_contents($linktoGame,FALSE,$context);$first_step=explode('',$url);$second_ste

php - 未知类型名称 'zend_string'

我正在尝试编译APCu使用make&&makeinstall缓存扩展。我收到有关无法找到zend_string或zend_long的编译错误。你们知道我需要什么样的扩展吗?谢谢:) 最佳答案 这些类型仅存在于PHP7/ZendEngine3中。您需要扩展的PHP5版本。 关于php-未知类型名称'zend_string',我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/342645

php - Laravel 5 $request->input 与 Input::get

只是想知道有什么区别:$username=$request->input('username');和$username=Input::get('username'); 最佳答案 没有区别,门面Input从request调用输入法。但是Input::get已被弃用,更喜欢$request->input而不是Input::getinput($key,$default);}/***Gettheregisterednameofthecomponent.**@returnstring*/protectedstaticfunctiongetFa

php - 可变产品选择器 : Getting the live selected values

在WooCommerce中,使用以下代码在简单和可变产品的产品价格后添加自定义标签:add_filter('woocommerce_variation_price_html','prices_custom_labels',10,2);add_filter('woocommerce_price_html','prices_custom_labels',10,2);functionprices_custom_labels($price,$product){//SetHEREyourcustomlabelsnames$per_dozen=''.__('perdozen','woocommer

php - 拉维尔 5.4 : Get logged in user id inside __construct()

我试图在构造函数中访问Auth::user()->id;但它总是返回错误Tryingtogetpropertyofnon-object。我在laravel文档中研究了Session在构造函数内部不可访问,并且还在SO上搜索了这个。我需要在构造函数中登录用户ID,因为我必须从数据库中获取数据并使其可用于所有方法。我当前的代码是:publicfunction__construct(){$this->middleware('auth');$induction_status=TrainingStatusRecord::where('user_id',Auth::user()->id)->whe

php - CodeIgniter 路由 : I keep getting a 404

我有一个包含以下内容的application/controller/login.php文件classLoginextendsController{functionLogin(){parent::Controller();}functionindex(){$this->mysmarty->assign('title','Login');$this->mysmarty->assign('site_media',$this->config->item('site_media'));$this->mysmarty->display('smarty.tpl');}}我的路由定义如下所示:$rou

php - Paypal 返回 URL - 使用 GET 参数?

这是我用来测试PaypalWebsitePaymentsStandard上传内容的一些简单代码。我的返回URL是http://mysite/index.php?module=store&show=order_confirm我完成了付款流程,当我到达最后并返回到页面时,它只是返回到index.php(即没有额外参数)。谁知道这是怎么回事 最佳答案 我不确定为什么Paypal正在做它正在做的事情,但我怀疑他们想要添加自己的GET参数的愿望正在抹杀你自己的。如果您可以使用mod_rewrite或类似的东西,您可能想尝试这样的事情:写一个改