开发者

Define function name with text field

开发者 https://www.devze.com 2023-01-11 01:59 出处:网络
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.

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.

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 y开发者_如何学编程ou 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.


Why do you need new functions? Sounds more like the same funxtion with different arguments, which can easily be your textfield value


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

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.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
        }
0

精彩评论

暂无评论...
验证码 换一张
取 消