mindapolis Posted May 1, 2011 Share Posted May 1, 2011 Hi, could someone please tell me why I'm getting unexpected $end error in the following code? <?php function documentType(){ echo <<<HEREDOC <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ` ` "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> } HEREDOC; ?> Quote Link to comment https://forums.phpfreaks.com/topic/235243-unexpected-end/ Share on other sites More sharing options...
teddyb Posted May 1, 2011 Share Posted May 1, 2011 <?php function documentType(){ echo <<<HEREDOC <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ` ` "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> HEREDOC; } ?> you included the bracket for closing the function in your string Quote Link to comment https://forums.phpfreaks.com/topic/235243-unexpected-end/#findComment-1208909 Share on other sites More sharing options...
KDM Posted May 1, 2011 Share Posted May 1, 2011 Hi, could someone please tell me why I'm getting unexpected $end error in the following code? <?php function documentType(){ echo <<<HEREDOC <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ` ` "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> } HEREDOC; ?> Why do you have the DOCTYPE in php tags? Try this. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ` ` "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <?php function documentType() { echo <<<HEREDOC } HEREDOC; ?> Quote Link to comment https://forums.phpfreaks.com/topic/235243-unexpected-end/#findComment-1208912 Share on other sites More sharing options...
teddyb Posted May 1, 2011 Share Posted May 1, 2011 KDM, that will most likely not work as it will come accross the first <? in <?xml version="1.0" encoding="UTF-8"?> and go into interpret mode Quote Link to comment https://forums.phpfreaks.com/topic/235243-unexpected-end/#findComment-1208915 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.