i want to ment a code block, but i have a line in my javascript block which has jquery and php both
like this
jq('.time_slot').each(function(index) {
var a = jq(this).autoplete({
serviceUrl:"<? echo $this->config->item('base_url'); ?>business/information/add/autoplete",
params: { suggessions_id:28767 }, //aditional parameters
onSelect:function(value,data){ jq(this).trigger('change'); }
});
});
with out this line
serviceUrl:"<? echo $this->config->item('base_url'); ?>business/information/add/autoplete",
i can ment this block using
/*
*/
but now i can not use it , also i tried with single line ments , like this
//jq('.time_slot').each(function(index) {
//var a = jq(this).autoplete({
//serviceUrl:"<? echo $this->config->item('base_url'); ?>business/information/add/autoplete",
// params: { suggessions_id:28767 }, //aditional parameters
// onSelect:function(value,data){ jq(this).trigger('change'); }
// });
// });
but for this line
serviceUrl:"<? echo $this->config->item('base_url'); ?>business/information/add/autoplete",
it is not working .
so i ended up with a very odinary solution like this
//serviceUrl:"
<? //echo $this->config->item('base_url'); ?>
//business/information/add/autoplete",
what is the best way to ment my code block , thank you in advance .
i want to ment a code block, but i have a line in my javascript block which has jquery and php both
like this
jq('.time_slot').each(function(index) {
var a = jq(this).autoplete({
serviceUrl:"<? echo $this->config->item('base_url'); ?>business/information/add/autoplete",
params: { suggessions_id:28767 }, //aditional parameters
onSelect:function(value,data){ jq(this).trigger('change'); }
});
});
with out this line
serviceUrl:"<? echo $this->config->item('base_url'); ?>business/information/add/autoplete",
i can ment this block using
/*
*/
but now i can not use it , also i tried with single line ments , like this
//jq('.time_slot').each(function(index) {
//var a = jq(this).autoplete({
//serviceUrl:"<? echo $this->config->item('base_url'); ?>business/information/add/autoplete",
// params: { suggessions_id:28767 }, //aditional parameters
// onSelect:function(value,data){ jq(this).trigger('change'); }
// });
// });
but for this line
serviceUrl:"<? echo $this->config->item('base_url'); ?>business/information/add/autoplete",
it is not working .
so i ended up with a very odinary solution like this
//serviceUrl:"
<? //echo $this->config->item('base_url'); ?>
//business/information/add/autoplete",
what is the best way to ment my code block , thank you in advance .
Share Improve this question asked Feb 29, 2012 at 7:54 Kanishka PanamaldeniyaKanishka Panamaldeniya 17.6k31 gold badges127 silver badges194 bronze badges4 Answers
Reset to default 2On runtime, if your php configuration's short_open_tag is enabled, those script enclosed in <? ?>
would have been parsed by php parser in the server before sending the html (that contains the said javascript with ment) to the browser.
So it should technically work if you use // to ment out that line, as the javascript parser won't be aware that the string was generated from php.
Make sure you have short_open_tag enabled or use <?php
instead of short tags (<?)
.
Ok, admittedly, this isn't pretty, but if you want to cancel out the mingled PHP and JavaScript in one fell swoop, you might consider wrapping the entire block in a PHP condition that always returns false, e.g:
<?php if (1 == 0) { ?>
jq('.time_slot').each(function(index) {
var a = jq(this).autoplete({
serviceUrl:"<? echo $this->config->item('base_url'); ?>business/information/add/autoplete",
params: { suggessions_id:28767 }, //aditional parameters
onSelect:function(value,data){ jq(this).trigger('change'); }
});
});
<?php } ?>
Ugly, I know, but undeniably quick and effective for big blocks of mixed code.
Afaik theres no better solution that you provided. PHP and JS ments are always separate, you can put JS ment into PHP's echo function.
PHP parser will always try to run code between blocks.
Imho best solution is to ment whole JS code using /* and */ and use single line ment to prevent PHP running php code block.
That is the best way already. Can't think of any better ways..