草庐IT

removable-storage

全部标签

PHP 简单 XML : Remove items with for

我可以使用以下方法从simpleXML元素中删除一个项目:unset($this->simpleXML->channel->item[0]);但我不能用afor:$items=$this->simpleXML->xpath('/rss/channel/item');for($i=count($items);$i>$itemsNumber;$i--){unset($items[$i-1]);}某些项目已从$items中删除(NetbeansDebug可以确认这一点)但是当我再次获取路径时(/rss/channel/item)没有任何内容被删除。怎么了? 最佳答

php - 如何为 Zend Cache Storage 设置过期时间?

我想在Zend文件系统缓存中存储一​​些XML,并让它在30分钟后过期。如何设置缓存持续时间/到期时间?我将Zend缓存用作组件,而不是在完整的ZF2应用程序的上下文中使用。$cache=\Zend\Cache\StorageFactory::factory(array('adapter'=>array('name'=>'filesystem','ttl'=>60,//keptshortduringtesting'options'=>array('cache_dir'=>__DIR__.'/cache'),),'plugins'=>array(//Don'tthrowexception

php - Laravel 5.4 Storage::delete() 不工作(找不到删除方法)

我在让Storage::delete($filepath);在Laravel5.4中工作时遇到问题。我已经搜索过其他有这个问题的人,但大多数人似乎都犯了错误,就是提供的文件路径没有前面的/,但这不是我的问题。我正在使用useIlluminate\Support\Facades\Storage;(根据LaravelDocs),我注意到我在PHPStorm中收到一个错误,提示Methoddeletenotfoundin照亮\支持\立面\存储。我的代码看起来像;get()->first();Storage::delete($image->filepath);returnFiles::dest

php - Drupal 表单 API 和 $form_state ['storage' ] 在页面刷新时被销毁

我有一个显示两个提交按钮的表单。第一个提交按钮将$form_state['storage']设置为一个值。然后第二个提交按钮读取这个$form_state['storage']值。如果设置了该值,则会显示一条成功消息。如果未设置该值,则会显示一条失败消息。这是将重现我的问题的代码:functionmymodule_test_admin(){returndrupal_get_form('mymodule_test_form');}functionmymodule_test_form(&$form_state){$form['mymodule_test_form1']=array('#ty

php - WooCommerce 'remove_action' 在 'init' Hook 中不起作用

我正在尝试修改WooCommerce产品过滤器插件以将过滤器添加为而不是"col-md-6".在functions.php中,我删除了Hook到创建col-md-6的函数的操作。,编写了创建row的新函数s,并添加了与我的新功能Hook的操作。请参阅下面的代码。functionfilter_styling(){echo'';}functionfilter_styling2(){echo'';}functionproduct_category_filter_changes(){remove_action('woocommerce_before_main_content','oxy_bef

php - 如何删除 php 中的单行注释(例如 "//remove this comment")?

我想使用正则表达式从我的代码中删除所有单行注释(例如//comments)。到目前为止,我正在使用:preg_replace('/\/\/(.*)/','',$html);但它也会删除像http这样的字符串://example.com. 最佳答案 也许更好的方法是使用PHP引擎本身,也许使用token_get_all().该函数会将PHP脚本标记化,因此您可以完全按照PHP查看它的方式查看它,从而删除或替换注释。单独使用正则表达式执行此操作充其量只是一场噩梦,而且很可能根本不可能。 关于

php - "Call-time pass-by-reference has been removed"

我正在尝试使用此存储库在Dotcloud上部署Wordpress,但日志中出现错误:18:59:19:[www.0]Runningpostinstallscript...18:59:21:[www.0]PHPFatalerror:Call-timepass-by-referencehasbeenremovedin/home/dotcloud/rsync-1353715101184/dotcloud-scripts/feed-wp-config.phponline86查看line86infeed-wp-config.php,内容如下:$content=preg_replace('/(de

php - 发生客户端错误 : Could not create storage directory:/tmp/Google_Client/00

此错误对YoutubeAPIv3.0意味着什么:Aclienterroroccurred:Couldnotcreatestoragedirectory:/tmp/Google_Client/00我在Google的文档中使用PHPYoutubeAPI找到here. 最佳答案 我在不更改GoogleAPI的任何行的情况下解决了这个问题。在您的PHP代码中,您只需要指定缓存文件夹所在的位置:$config=newGoogle_Config();$config->setClassConfig('Google_Cache_File',arra

PHP/Zend : How to remove all chars from a string and keep only numbers

我只想保留数字并从变量中删除所有字符。例如:input:+012-(34).56.(ASD)+:"{}|78*9output:0123456789 最佳答案 这是一般的做法:$numbers=preg_replace('/[^0-9]+/','','+012-(34).56.(ASD)+:"{}|78*9');echo$numbers;输出:0123456789 关于PHP/Zend:Howtoremoveallcharsfromastringandkeeponlynumbers,我们在

php - Symfony2 表单集合 : How to remove entity from a collection?

我尝试从集合中删除实体,但它不起作用。我想我在某处有错误,但我不知道在哪里。这是我的updateAction中的代码:$em=$this->getDoctrine()->getEntityManager();$entity=newPerson();if(!$entity){throw$this->createNotFoundException('UnabletofindPersonentity.');}$editForm=$this->createForm(newPersonType(),$entity);$deleteForm=$this->createDeleteForm($id)