草庐IT

register-allocation

全部标签

php - 非破坏性的 spl_autoload_register

我想在我正在开发的wordpress插件中通过spl_autoload_register使用类的动态加载,但问题是它不能干扰此功能的预先存在的实现。在我最初的尝试中://registeranautoloaderfunctionfortemplateclassesspl_autoload_register('template_autoloader');functiontemplate_autoloader($class){includeLG_FE_DIR."/includes/chart_templates/class.{$class}.php";}似乎可以加载我自己的类,但同时会导致其

php - 为什么我要使用 spl_autoload_register 而不是 include 或 require 类和函数?

我不明白spl_autoload_register或autoload是做什么的。为什么我不直接使用include或require?我没有看到明确的答案。 最佳答案 自动加载函数或类的优点是:如果您有很多类,则无需手动包含它们。以ZendFramework为例:您不想手动加载所有这些类。使用自动加载器,只需创建一个新类并开始在所有(启用自动加载器的)文件中使用它。仅加载请求中实际使用的文件,从而可能节省资源。如果您只使用50个文件中的10个,为什么要加载其他40个?它迫使你有一个合理的目录布局(毕竟,你需要一些规则,这样你的自动加载器

php - 如何去掉 "Quick edit"列表页中的 "register_post_meta"选项

我在列表页面中自动使用register_post_type它是四个操作Edit/QuickEdit/trash/View。我想从列表页面中删除“快速编辑”选项。我该怎么做。 最佳答案 /*------------------------------------------------------------------------------------removequickeditforcustomposttypevideosjusttocheckiflessmemconsumption----------------------

php - WordPress:自定义帖子类型,将数据发送到 "register_meta_box_cb"Arg

我正在向WordPress网站添加多个自定义帖子类型,并且我正在尝试通过使用变量和合并函数来优化代码。我能够将2个变量发送到用于register_post_type的create_rma_project_post_type函数。我想对附加metabox创建函数的参数做同样的事情。下面的第一个代码完全有效。它使用register_meta_box_cb调用add_project_metaboxes:add_action('init',create_rma_project_post_type('project','our-people'));functioncreate_rma_proje

php - 加载类时 spl_autoload_register 问题

所以我之前已经在这里问过这个问题,但是提供的解决方案对我不起作用。这是我的设置:/mylib/Vendor/Module/MyClass.php/document_rootindex.php这是我的index.php这是我的MyClass.php我的echo没有显示任何东西。显然我的课也没有加载。相反,我得到了这个错误。Fatalerror:CalltoundefinedmethodMyClass::test()in//index.phponline29请帮忙。我已经坚持了很长一段时间,而我的其余发展都在受苦。我尝试移动到spl_autoload_register()只是因为这是推荐的

PHP fatal error : Allowed memory size of 1073741824 bytes exhausted (tried to allocate 16777216 bytes)

我在我的16GBMacBookPro上运行了composerinstall,我得到了这个⚡️distributor-portalcomposerinstallLoadingcomposerrepositorieswithpackageinformationUpdatingdependencies(includingrequire-dev)PHPFatalerror:Allowedmemorysizeof1073741824bytesexhausted(triedtoallocate16777216bytes)inphar:///usr/local/bin/composer/src/Co

php - 如何关闭 php.ini 中的 Register_globals? hostgator wordpress 服务器

我在hostgator服务器上的wordpress上运行电子商务主题,并出现此错误。Securitywarning:setthevalueregister_globalsinthephpinitoOff!!Thisthemewillnotworkcorrectlyotherwise.我在任何文件夹中都找不到php.ini。我尝试使用添加的命令创建一个文件,并按照谷歌的建议将其放入根目录,但没有成功。有什么建议吗?否则。 最佳答案 您应该放在根文件夹中的文件不是php.ini,而是.htaccess。确保它包含这一行:php_flag

php - spl_autoload_register 在包含的文件中不起作用

我正在使用spl_autoload_register为了加载类。我有一个index.php文件,其中包含一个init.php文件。spl_autoload_register函数在init.php文件中调用。在index.php文件中,它正常工作:我可以创建类和东西,它们的名称已解析。但后来,在index.php中,我包含了另一个文件work.php来完成一些特定的任务。奇怪的是,在work.php中,找不到我正在使用的类。如果我在work.php中再次调用spl_autoload_register,类就可以解析了。真正奇怪的是这种行为并不一致:在我的测试服务器上,我不必复制spl_au

PHP [面向对象] : Memory allocation for Inheritance

请看下面的代码:classA{publicx=5;publicy=6;publicz=7;}classBextendsA{publicm=1;publicn=2;}$a=newA();$b=newB()从上面的代码可以看出,$a正在分配x内存量,而$b正在分配y内存量;现在我的问题是下面哪一个是正确的?x>yx 最佳答案 这些是我的数字:Startingallocation62480AllocatedmemoryfornewA()328AllocatedmemoryfornewB()496因此x这两个类定义是等价的classBext

php - 弃用 : Function session_register() is deprecated and Cannot modify header information

我用sql创建了一个简单的登录系统它有4个主要组件index-询问用户名并通过checklogin-检查凭据登录成功首页-登录成功后的登陆页面错误生成在文章末尾给出Index.phpasksforusernameandpassNottinghamUni AuthenticationUsernamePassword   checklogin.phpchecksforthecredentialsIfitssuccessitgoestohomepage.phplogsuccess.phpisbelowLoginSuccessfulthesecodesa