АП
Size: a a a
АП
M
M
АП
АП
M
АП
АП
c
АП
АП
M
АП
АП
M
АП
Д
<?php
/**
* Plugin Name: My Plugin
**/
$tag = 'lead_form';
$func = 'form';
add_shortcode( $tag , $func );
public function form(){
return 'myform';
}
<?php
/**
* Plugin Name: My Plugin
**/
class LeadGenForm {
$tag = 'lead_form';
$func = 'form';
add_shortcode( $tag , $func );
public function form(){
return 'myform';
}
}
$LeadGenForm = new LeadGenForm();
То получаю ошибку, Parse error: syntax error, unexpected '$tag'
Подскажите, как правильно такое делать.KD
add_shortcode( 'lead form', [ $this, 'form' ] )
ST
class LeadGenForm {
public $tag, $func;
public function __construct()
{
$this->$tag = 'lead_form';
$this->$func = 'form';
add_shortcode($this->$tag, [$this, 'form']);
}
public function form()
{
return 'myform';
}
}
$LeadGenForm = new LeadGenForm();
class LeadGenForm {
public $tag, $func;
public function __construct($tag)
{
$this->$func = 'form';
add_shortcode($tag, [$this, 'form']);
}
public function form()
{
return 'myform';
}
}
$tag = 'lead_form';
$LeadGenForm = new LeadGenForm($tag);
SB
<?php
/**
* Plugin Name: My Plugin
*/
class LeadGenForm {
var $tag = 'lead_form';
var $func = 'form';
function __construct() {
add_shortcode( $this->tag, array( $this, $this->func ) );
}
public function form() {
return 'myform';
}
}
$LeadGenForm = new LeadGenForm();