I'm trying to apply the class effect
into input type="submit"
whenever its parent form action contains the string special
.
I'm using the following code, but Dreamweaver tells me there are syntax error in lines 15,16,22:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
$case1 = "special";
$item = "aaa";
$item = "something";
function get_class( $slug ) {
$class_map = array(
'special' => 'effect',
'none' => '',
// .. you could add others here if appropriate
return ( isset( $class_map[ $slug ] ) ) ? $class_map[ $slug ] : ''; //line 15
); // line 16
?>
<HTML>
<body>
<form action="/go/<?= $item ?>/<?php echo $case1 ; ?>" method="POST" target="_blank">
<input name="a" type="hidden" value="<?php echo $a; ?>"/>
<input type="submit" class="<?= get_class( $case1 ); ?> general-class" value="Click Me"></form> // line 22
</body>
</HTML>
The output is empty, and no errors are being displayed when I try running the file.
What's wrong?
Edit 2 - Updated code:
Now getting fatal error on line 16:
Fatal error: Cannot redeclare get_class() on line 16
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
$case1 = "special";
$item = "aaa";
$item = "something";
function get_class( $slug ) {
$class_map = array(
'special' => 'effect',
'none' => '',
// .. you could add others here if appropriate
);
return ( isset( $class_map[ $slug ] ) ) ? $class_map[ $slug ] : '';
} // line 16
?>
<HTML>
<body>
<form action="/go/<?= $item ?>/<?php echo $case1 ; ?>" method="POST" target="_blank">
<input name="a" type="hidden" value="<?php echo $a; ?>"/>
<input type="submit" class="<?php get_class( $case1 ); ?> general-class" value="Click Me"></form>
</body>
</HTML>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…