Answer the question
In order to leave comments, you need to log in
How correct is it to use php wrappers for js code?
Many js plugins have php example libraries for quick connection and use in my projects, I myself use this approach, and it seems convenient to me. To what extent is it considered correct, isn't it a g ... code?
Answer the question
In order to leave comments, you need to log in
The plugin requires functionality on the server side. This is fine.
Sometimes, when using a ready-made JS code, I do not use its back-end part and write it myself if I need to do another action, and not the one that the author meant.
This happens very often: for example, they use the wrong database or other tools.
So take the server side as an example.
here we mean the generation of js code using php
for example
$jgrid->addColumns([..]);
$jgrid->setName('mygrid');
echo $jgrid->init();//на выходе js код плагина
And in a different way, you can’t transfer data from the backend to the JS level.
Well, so that they were immediately, without ajaxes.
So this is the norm.
1. Of course, real-time JS code generation in PHP, shit code. Then there will be a desire to write like this
<script>
var jsVar = <?= $phpVar?>;
</script>
<div data-some-value="12341"></div>
) , and php sets it there. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question