Click to See Complete Forum and Search --> : Hand work mini code like bbmode
deep_fire
07-10-2005, 07:53 PM
<?function allsee($string)
{
if(strstr($string,"")==true)
{
$dizi=explode("",$string);
$dizisay=count($dizi);
for($i=0;$i<$dizisay;$i++)
{
if(strstr($dizi[$i],"")==false)
{
$str=$str.$dizi[$i];
}
else
{
$dizi2=explode("",$dizi[$i]);
$dizisay2=count($dizi2);
for($j=0;$j<$dizisay2;$j++)
{
$jo=$j%2;
if($jo==0)
{
$pen="_blank";
$str=$str.'<a href='.$dizi2[$j].' target='.$pen.'>'.$dizi2[$j].'</a>';
}
else
{
$str=$str.$dizi2[$j];
}
}
}
}
}
elseif(strstr($string,"[link]")==false)
{
$str=$string;
}
if(strstr($str,"")==true)
{
$dizi5=explode("",$str);
$dizisay5=count($dizi5);
for($t=0;$t<$dizisay5;$t++)
{
if(strstr($dizi5[$t],"")==false)
{
$str=$dizi5[$t];
}
else
{
$dizi6=explode("",$dizi5[$t]);
$dizisay6=count($dizi6);
for($h=0;$h<$dizisay6;$h++)
{
$ho=$h%2;
if($ho==0)
{
$str=$str.'<table align="center" bgcolor="FFFFFF" width="95%" border="0" cellspacing="0" cellpadding="0" class="code"> <tr> <td>'.highlight_string($dizi6[$h], true).'</td> </tr></table>';
}
else{
$str=$str.$dizi6[$h];
}
}
}
}
}
elseif((strstr($str,"[code]")==false) && (strstr($string,"[link]")==false))
{
$str=$string;
}
if(strstr($str,"")==true)
{
$dizi3=explode("",$str);
$dizisay3=count($dizi3);
for($l=0;$l<$dizisay3;$l++)
{
if(strstr($dizi3[$l],"")==false)
{
$str=$dizi3[$l];
}
else
{
$dizi4=explode("",$dizi3[$l]);
$dizisay4=count($dizi4);
for($k=0;$k<$dizisay4;$k++)
{
$ko=$k%2;
if($ko==0)
{
$str=$str.'<center><img src='.$dizi4[$k].'></center>';
}
else
{
$str=$str.$dizi4[$k];
}
}
}
}
}
elseif((strstr($string,"[img]")==false) && (strstr($string,"[code]")==false) && (strstr($string,"[link]")==false))
{
$str=$string;
}
$str=nl2br($str);return $str;
}
?>
thorpe
07-10-2005, 08:02 PM
and?
halojoy
07-10-2005, 08:03 PM
Still A nightmare.
But maybe there is a chance we can understand something now.
your script is probably doing a good job - else you wouldnt show it here .. ;)
<?php
/*****
A little advice about php scripting good rules:
1. - give variables 'english' names
.... I know a terrible exmaple, where script made logfile in Portuguese!!
.... when was an error, you had to go to school learn portuguese
.... before fixing whatever error
2. - let the name of $variable say something about what data it holds
***/
// tells us just about nothing
$ab = "Welcome to my website";
/***
today you may know what $ab stands for - but if you want to update/change next year ...
you have to learn what it is all about - for second time in your life
This gives info that makes easier understand, use and modify your script
And in a language, that has been accepted 'programming standard'
since the first simple programs
written in BASIC: ... PRINT "Hello world" --- 'PRINT' is an english word for echo
'echo' is another english word for display
***/
$welcome_msg = "Welcome to my website";
?>
halojoy is from Sweden - he is proud being swedish (wouldnt have wanted to be known as an USA american = war)
- but halojoy is using 'english' as a tool for communication
- as we have no better international tool, for moment
:cool:
deep_fire
07-10-2005, 08:05 PM
this is a prototip open source. You can develope more
deep_fire
07-10-2005, 08:11 PM
Thank you mannn :D
thorpe
07-10-2005, 08:13 PM
i think i'll stick to regular expressions for that kind of work thankyou. all those loops are making me dizzy.
deep_fire
07-10-2005, 08:26 PM
:d
halojoy
07-11-2005, 09:05 AM
i think i'll stick to regular expressions for that kind of work
thankyou.
all those loops are making me dizzy.Yes, and there are several resons for this dizziness.
Among other, the unfortunate choice of $variable names
See also my first Reply in this thread.
I have changed, edited quite a bit!!
;)
planetsim
07-11-2005, 09:33 AM
Talk about little in coding style. Your code is lets say very compressed, there is no style to it. May I suggest picking a common style and sticking to it as best as you can.
<?php
if(true){
echo 1;
}
?>
Is sort of what you have done its little and easily read for that but just think of this with 1000+ lines of code not only are you going to get dizzy reading it, but 6months down the track your gonna waste hours maybe even days trying to understand what you did. (Commenting would help too, I counted about 0 Comments).
My above example could be easily formatted like this
<?php
if (true)
{
echo 1;
}
?>
or
<?php
if (true) {
echo 1;
}
?>
Your tab/space could vary I use 4 spaces, and generally use the 1st example of formatting code since it looks cleaner. Also commenting would be good but for my example it is pointless since true is always true you will always get 1, that and my example is small. Like halojoy said use descriptive variable names, again pick a style PHP tends to have a few common ones, Perl, and Java.
Perl Style is
$user_name = "myvar";
While Java Style is
$userName = "myvar";
With descriptive usernames, and use of a style you can usually keep commenting down quite a bit although you should still comment a lot too.
Ill wait a little longer once you have fixed the code up to be readable before I comment on it, that and im getting a headache from trying to keep track.
deep_fire
07-11-2005, 12:01 PM
Talk about little in coding style. Your code is lets say very compressed, there is no style to it. May I suggest picking a common style and sticking to it as best as you can.
<?php
if(true){
echo 1;
}
?>
Is sort of what you have done its little and easily read for that but just think of this with 1000+ lines of code not only are you going to get dizzy reading it, but 6months down the track your gonna waste hours maybe even days trying to understand what you did. (Commenting would help too, I counted about 0 Comments).
My above example could be easily formatted like this
<?php
if (true)
{
echo 1;
}
?>
or
<?php
if (true) {
echo 1;
}
?>
Your tab/space could vary I use 4 spaces, and generally use the 1st example of formatting code since it looks cleaner. Also commenting would be good but for my example it is pointless since true is always true you will always get 1, that and my example is small. Like halojoy said use descriptive variable names, again pick a style PHP tends to have a few common ones, Perl, and Java.
Perl Style is
$user_name = "myvar";
While Java Style is
$userName = "myvar";
With descriptive usernames, and use of a style you can usually keep commenting down quite a bit although you should still comment a lot too.
Ill wait a little longer once you have fixed the code up to be readable before I comment on it, that and im getting a headache from trying to keep track.
Thanx for your tutorial so I learned
PHP Builder
Copyright WebMediaBrands Inc. All Rights Reserved.