我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

php创建没有变量传递函数的类

Lets say I have a class with a function in it:

classes.php

 class Foobar{
        function writeWord($word){
               return $word;
        }
 }

On the page that i call this class i need to initialize the class, then call it later.

php2.php

require_once('classes.php');
$something = new Foobar();

 echo $something->writeWord('Dog');

The problem here is that php comes back and says Foobar is missing arguments on line 1. how can I solve this?

近期文章

  • 使用MySQL JOINS创建嵌套或多维数组
  • 从另一个wordpress安装中显示用户元
  • 防止号码到电话号码链接的移动格式转换?
  • 使用jquery的依赖下拉列表无法填充html文件
  • 在准备好的声明的准备部分中有变量的问题
  • DateTime :: createFromFormat即使不应该返回false
  • ZipArchive :: addEmptyDir不是在ubuntu 3.15和PHP 5.3.10中创建空目录
  • 用形式动作后置方法代替获取按钮的值
  • 如何递归存储项目?
  • 当Outlook 2010下载图像时,PHP脚本会发送多封电子邮件
  • 使用AJAX和jQuery来存储数据
  • 在Laravel 5.1中整理控制器
  • 递归查找所有数组值
  • 列出所有选项字符串的组合,同时遵循提供的数组的顺序和特定选项的规则 - php
  • mysql查询在循环内部不起作用
  • 将Opencart Sitemap拆分为多个列
  • codeigniter调试结果在不同的计算机上
  • php 5.5可以读写但不会执行
  • 产品缺货后的Woocommerce电子邮件
  • 管理面板中的产品类别为空

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华