用文本字段定义函数名称 [英] Define function name with text field

查看:85
本文介绍了用文本字段定义函数名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是一个真正的PHP新手(我知道我在尝试运行之前可以走路),但我想知道是否可以通过文本字段定义函数名称。

I'm only really a novice with PHP (and I know I'm sortof trying to run before I can walk), but I would like to know if it is possible to define a functions name via a textfield.

目前,我正在使用Wordpress,因此我可以使用add_option将某些内容添加到数据库中以存储数据等,这很方便。我的想法是为幻灯片插件,它允许你有无限的幻灯片。

Currently, I am working with Wordpress so I can use add_option to add something to the database to store data, etc, which is handy. My idea is for a slideshow plugin which allows you to have unlimited slideshows.

这将通过在文本框中输入名称然后单击提交按钮来存储名称。这个名字将被赋予一个可用于显示特定幻灯片的功能。这可能吗?

It would work by typing the name into the text box then clicking the submit button to store the name. This name would then be given to a function which can be used to display that specific slideshow. Is this possible?

很抱歉,如果这看起来很混乱。我知道我想要达到的目标,但我不知道如何(但我愿意学习)。谢谢。

Sorry if this seems confusing. I know what I want to achieve, I just don't have a clue how (but I am willing to learn). Thanks.

推荐答案

1.您的插件管理页面允许命名和创建幻灯片,例如创建带有标题的帖子或图库,并添加图片。

1.your plugin admin page allows naming and creating slideshows, like creating a post or a gallery with a title, and adding images.

2.您可以在您的主题中放置一个函数调用,以在其中显示幻灯片:

2.you place a function call in your theme where you want a slideshow to appear:

if(function_exists('display_slideshow')){display_slideshow($slideshow_name)};

3.函数display_slideshow()包含在您的插件文件中。

3.the function display_slideshow() is included in your plugin file.

function display_slideshow($slideshow_name){
            //get slideshow stuff from the database, 
            //using the name of the show passed as arg
            //write your html and php to show the images the way you design
        }

这篇关于用文本字段定义函数名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆