[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]

/prog/ - Programming

Programming board

Catalog

Name
Email
Subject
Comment *
File
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Embed
(replaces files and can be used instead)
Options
Password (For file and post deletion.)

Allowed file types:jpg, jpeg, gif, png, webm, mp4, pdf
Max filesize is 8 MB.
Max image dimensions are 10000 x 10000.
You may upload 1 per post.


f596cd No.2236

FUCKING SHIT STUPID ASS PHP, WHY AIN'T THIS WORKING!

function SYS_newsFeed(){
$file = websiteURL()."/assets/database/feeds/news.txt";
$text = readfile($file);
$newsfeed = parseCode("$text");
return(parseCode($newsfeed));
}

It throws up exactly what is in the text file, but with 54 at the end AND parseCode doesn't fucking do its job and replace "%a%" with "<span style='color:#99ff99'>" what the hell am I doing wrong?

7b3ee0 No.2237

>>2236

>what the hell am I doing wrong?

using PHP


f596cd No.2239

Besides that?


279eea No.2243

>>2239

>Besides that?

Asking /prog/


31a201 No.2248

>$newsfeed = parseCode("$text");

>return(parseCode($newsfeed));

why are you running parsecode twice?


00cb97 No.2253

>>2248

I don't know PHP, but it would be nice to know why he's doing this


9889bc No.3916

Try:



function SYS_newsFeed(){
$file = websiteURL()."/assets/database/feeds/news.txt";
$text = file_get_contents($file); //reads the contents of the file to a string variable.
$text = preg_replace("/%a%/","<span style=\"color:#99ff99\">",$text); //uses regex to do the replacement, I don't know parseCode.
return($text);
}

//to call it use:
echo(SYS_newsFeed());

readfile will attempt to open a file, read it into memory and output its contents immediately. It returns true if this is successful and false if it fails. The 54 you get at the end of the file is the number of bytes in the file, its printed by readfile.

file_get_contents reads the file contents into a string variable, it includes newlines.

Your parseCode will probably work if you give it the string returned by file_get_contents, but you only need to use it once. You also don't need to use so many variables, the operation performed on the right of the assignment operator (=) happens before the actual assignment, so you can do something like $var = 2; $var = $var * 3; and it will make $var 6.


9889bc No.3917

>>3916

>10 months ago

Shieeeeeet.


70bdef No.3930

>>3917

Slow and steady wins the race little friend.




[Return][Go to top][Catalog][Post a Reply]
Delete Post [ ]
[]
[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]