如何将PHP代码添加到占位符?

时间:2015-12-16 15:22:20

标签: php

我有脚本,我设置占位符:

 $mailargs = array(

                'nametxt' => '',

                'emailtxt' => '',

                'nameholder' => 'Your Name',

                'emailholder' => 'Your Email Address',

                'submittxt' => 'GO',

                'jsthanks' => true,

                'thankyou' => 'Thank you for subscribing to our mailing list'

            );

现在我需要将这部分代码放在nameholder中:

<?php _e('Stay in touch with latest news,events and exhibitions by subscribing to our official newsletter', 'wp-test'); ?>

有任何建议怎么做?

1 个答案:

答案 0 :(得分:1)

您可以在数组中包含_e()函数:

$mailargs = array(

    'nametxt' => '',

    'emailtxt' => '',

    'nameholder' => _e('Your Name','wp-test'),

    'emailholder' => _e('Your Email Address','wp-test'),

    'submittxt' => _e('GO','wp-test'),

    'jsthanks' => true,

    'thankyou' => _e('Thank you for subscribing to our mailing list','wp-test')
);

这将在$mailargs数组中为您提供所需的结果。