Jump to content

section/subforum I miss here


rain13

Recommended Posts

I strongly miss sub forum for example scripts/functions. Such forum would allow users to share they're work and others would be able to rate they're work. This wouldn't be place for asking help, but for sharing what you've done. An other good thing about such section would be that other people can search functions for they're code.I don't have any good example functions to post but some standard functions I have:FileWrite($sFile,$sString) - writes string to fileFileRead($sFile) - returns file contents.By standard I meant that you can just copy those functions to any php script and You dont have to worry about wether it's completeble with your's php or not. It doesnt require any extra variables, or classes or anything, you can leave it as it is and it works that simple.Those functions would simplify file reading/writing. To read/write file you would have to open file you would have to 1)open file 2)read/write file 3) close file. which would mean 3 lines code.When I fist started php I was like confused because fread didn't return me contents, then it took me a while to figure out that I need to open file first. Then I had long and messy sources.After that I decided to write standard functions for these actions and my code is much cleaner.

function FileWrite($sFile,$sString){if (strlen($sString) > 0){	$hFile = fopen($sFile, 'a');	if	($hFile){		fwrite($hFile, $sString);		fclose($hFile);		return true;	}}return false;}function FileRead($sFile){	$fd = fopen ($sFile , "r");	if ($fd) {		if (filesize($sFile) > 0){			$fstring = fread ($fd , filesize ($sFile));			fclose($fd);			return $fstring;		}else{			fclose($fd);			return "";			}	}	else{		echo '<font color="#FF0000">ERROR:</font> Can not read file '.$sFile;		return false;	}}

If there were forum section called "Example scripts" people who are new to programming could quickly find code. For example if some one is googling for file read operation, he would find FileRead($sFile); from example scripts section and he wouldn't have to google a hour just to find out that he needs to usse fopen and then handle returned by fopen to read file.Other good thing about example script section is that when you happen to find function/script for your needs, you can learn from it. You see how something is done, and then just learn from it.This is just 1 example of how beautifully such forum section works http://www.autoitscript.com/forum/forum/9-example-scripts/ See - only example scripts there. Why don't we have such section in this site?Simple rule would for such section be: You are not allowed to create topic just to advertise your site.

Link to comment
Share on other sites

Oh, I didnt know these functions. As I mentioned I don't have any good function. I just used those functions to explain the idea if example scripts forum. I mean if some one had function that is not duplicate just of some other func, they cold share it. Main idea would be feed back. I posted function, you commented it. That's exactly how example scripts section should work in my opinion. Example scripts section could also contain examples whole web application. Like if someone made some quick chat like thing using php + javascript he could post it on example scripts if he want.I dont have any good ideas to say in here but I believe that many people in this site would have something unique to post that section. And even if it turns out that no one wants to use such section (which I don't believe), administrators can always delete it.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...