Mr Chris Posted September 26, 2007 Share Posted September 26, 2007 Hi All, I have a piece of code where I want to break some text up and place an advert in the middle: <?php $mpu = include 'mputag.php'; ?> <body> <?php $len = (strlen($story) >> 1); echo preg_replace( "/(?<=.{{$len}})\s/s", "<br /><br />".$mpu."<br /><br />", nl2br($story), 1); ?> </body> Now in this line "<br /><br />".$mpu."<br /><br />", it does not include the php file I ask it to, it just outputs the number 1? Can anyone help me. Thanks Chris Quote Link to comment https://forums.phpfreaks.com/topic/70735-include-problem/ Share on other sites More sharing options...
HuggieBear Posted September 26, 2007 Share Posted September 26, 2007 By assigning the result of include('mputag.php') to $mpu, you're giving it a value of either true or false (1 or 0) hence the display of the number 1. I'm guessing include isn't actually the function you want. What does this mputag.php file contain and what are you trying to display? Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/70735-include-problem/#findComment-355595 Share on other sites More sharing options...
Mr Chris Posted September 26, 2007 Author Share Posted September 26, 2007 Thanks, It contains adverts I wish to display within IFRAMES, which also calls in php. So how could I call it in then rather than using include? <iframe src="http://dhdsite.com/<? echo $name; ?>/;dcopt=ist;sz=300x250;ord=<? echo $ord; ?>?" width="300" height="250" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling=no borderCOLOR="#000000"> <script language="JavaScript" src="http://ad.doubleclick.net/adj/<? echo $name; ?>/;dcopt=ist;sz=300x250;abr=!ie;ord=<? echo $ord; ?>?" type="text/javascript"></script> <noscript><a href="http://ad.doubleclick.net/jump/<? echo $name; ?>/;sz=300x250;abr=!ie4;abr=!ie5;abr=!ie6;ord=<? echo $ord; ?>?" target="_blank"><img src="http://ad.doubleclick.net/ad/<? echo $name; ?>/;sz=300x250;abr=!ie4;abr=!ie5;abr=!ie6;ord=<? echo $ord; ?>?" width="300" height="250" border="0" alt=""></a></noscript> </iframe> Quote Link to comment https://forums.phpfreaks.com/topic/70735-include-problem/#findComment-355604 Share on other sites More sharing options...
HuggieBear Posted September 26, 2007 Share Posted September 26, 2007 If you're using it in a preg_replace() function then you probably want to use file_get_contents()... <?php $mpu = file_get_contents('mputag.php'); ?> <body> <?php $len = (strlen($story) >> 1); echo preg_replace( "/(?<=.{{$len}})\s/s", "<br /><br />".$mpu."<br /><br />", nl2br($story), 1); ?> </body> I don't know how it'll cope with the nested <?php tags Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/70735-include-problem/#findComment-355606 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.