$sn = 0;//increment the serial number, then add the sn to job for($x = 0; $x<20; $x++) { $sn++; $added_date = "10/10/10"; $job_title = "new job"; $salary = $sn*1000; $cd = "27/10/2017";//the closing date $ins = "some institution";//the institution for the vacancy $notes = "some notes here";//any notes about the jobs $sn_div = "<div class='sn_div'>".$sn."</div>"; $ad_div = "<div class='ad_div'>".$added_date."</div>"; $job_div = "<div class='job_div'>".$job_title."</div>"; $salary_div = "<div class='salary_div'>".$salary."</div>"; $cd_div = "<div class='cd_div'>".$cd."</div>";//cd means closing date $ins_div = "<div class='ins_div'>".$ins."</div>";//ins means institution $notes_div = "<div class='notes_div'>".$notes."</div>"; /*erroneous line*/$job_no = "job"+$sn;//to create the job rows $$job_no = "<div class='job_wrapper'>".$sn_div.$ad_div.$job_div.$salary_div.$cd_div.$ins_div.$notes_div."</div>"; echo $$job_no;//and then echo each job }
that I had code that looped and created new html div elements. The code worked fine and the elements were generated, but I got the same warning in error_log.
After reading other useful answers, I thought I was summing up the string and the number in the wrong string. So I changed the code on this line to
$job_no = "job"&&$sn;
Now the code works as before, but without warnings this time. Hope this example is helpful to someone.
Neo Nov 28 '17 at 3:00 2017-11-28 03:00
source share