Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/70735-include-problem/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/70735-include-problem/#findComment-355595
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/70735-include-problem/#findComment-355604
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/70735-include-problem/#findComment-355606
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.