Jump to content

Recommended Posts

I'm trying to make a highlight replacing function just like GeSHi (but I need to mod it for my needs and stuff)
My code is:
[code]
<?php
$string = include("test.php");
$r = "<a href='whoknowswhat.html'>apples</a>";
$p = "apples";
$s2 = eregi_replace($p, $r, $string);
echo $s2;
?>
[/code]
i THINK that my $s2 declaration has no problems and I think the problem resides in $string. Is my declaration incorrect, 'cause once I change $string into something like "I love to eat apples" or something, the eregi_replace function works like magic.
you cannot assign a variable the value of include as include doesnt return anything. If you want to get the contents of the file you'll want to use file_get_contents function which returns the contents of that file.
Ya, thanks guys. I happened to stumble over the idea maybe "file reading" would do.
Then I searched it up on php.net. It gave me that, but didnt work, and on the bottom it said "see also" and it gave me "file_get_contents"
So! Thanks for helping out ^^
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.