Specs: ci v3, php v8
Hey i ran into this error:
Exception: syntax error, unexpected end of file (file path here) (line number)
File code:
<?php
/*
$text: String
- The text inside the button
*/
get_instance()->load->helper("string");
$classes = [
"button" => [
"className" => "button-" . random_string("alnum", 8),
"style" => [
"width" => "100%",
"background" => "linear-gradient(180deg, #54C3E4 0%, #36749C 100%)",
"box-shadow" => "0px 15px 14px rgba(91, 142, 190, 0.2)",
"border" => "none",
"border-radius" => "40px",
"padding" => "14px 0px",
"color" => "white",
],
],
];
?>
<style>
<?php
foreach ($classes as $class) :
?><?= "." . $class["className"] ?> {
<?php foreach ($class["style"] as $styleAttr => $styleVal) : ?><?= $styleAttr ?>: <?= $styleVal ?>;
<?php endforeach; ?>
}
<? endforeach; ?>
</style>
<button button"]["className"] ?>"><?= $text ?></button>
<script>
// Events to handle disable & enable states of this button
$(".<?= $classes["button"]["className"] ?>").on("enable", function() {
$(this).css({
cursor: "pointer",
opacity: 1,
}).removeAttr("disabled");
});
$(".<?= $classes["button"]["className"] ?>").on("disable", function() {
$(this).css({
cursor: "default",
opacity: "0.5",
}).attr("disabled", true);
})
// Get this current script tag
let thisScript = document.currentScript;
// Push style into head
const style = $(thisScript).siblings("style");
$("head").append(style);
// remove this current script tag
$(thisScript).remove();
// Remove from memory to redeclare
delete thisScript;
</script>
This is some old script so please don't mind it's logic. This file script (file_name.php) is a view file which is working perfectly in other servers (locally and remotely). I can only guess there's some issues with the conf of apache or php...
CodePudding user response:
As @aynber suggested:
You're using a short tag on which may be throwing it off.
Which seem to solve this problem!
CodePudding user response:
Your problem is that a lonely }
is outside of tags.
<?php endforeach; ?>
}