So, I have this code.
$url = "www.google.com";
<script>
$( document ).ready(function() {
alert(<?=$url?>);
});
</script>
Sometimes this variable will be empty depending of what section of the page is loaded. The page that should echo the url is section 2 but not section three. The jquery code is set at the footer of the page. My knowledge of php is very limited, so I am wondering if I should set the variable to null or '' so that if it is empty it is "defined?". I could use the isset, but that is not an option.
$url = '';
$url = "www.google.com";
<script>
$( document ).ready(function() {
alert(<?=$url?>);
});
</script>
The code that loads the sections looks someting like this.
if(condition1){
} elseif(condition2){
$url = "www.google.com";
}else{
}