random1 Posted March 22, 2008 Share Posted March 22, 2008 Hi All, I'd like to know if it's possbile to set in code to make new lines in source code after a certain number of characters/ i.e. automatically put a new line in source (not <br />) after every 30 characters. I'm trying to keep my code clean. Link to comment https://forums.phpfreaks.com/topic/97343-new-lines-by-default/ Share on other sites More sharing options...
kenrbnsn Posted March 22, 2008 Share Posted March 22, 2008 Please explain your question better. Ken Link to comment https://forums.phpfreaks.com/topic/97343-new-lines-by-default/#findComment-498131 Share on other sites More sharing options...
Barand Posted March 22, 2008 Share Posted March 22, 2008 Are you saying that this <?php functiondrawWeb(){$ang=360/$th is->numpts;$cx=$cy=$this->size /2;imagesetthickness($this->im ,1);for($i=$this->firstAngle;$ i<=360;$i+=$ang){$a=-deg2rad($ i);$this->angles[]=$a;imagelin e($this->im,$cx$cy,$cx+$this-> radius1*cos($a),$cy+$this->rad ius1*sin($a),$this->webcolor); }$this->angles[]=-deg2rad($thi s->firstAngle);$rstep=$this->r adius2/5;for($r=$rstep;$r<=$th is->radius2;$r+=$rstep){for($i =0;$i<$this->numpts;$i++){imag eline($this->im,$cx+$r*cos($th is->angles[$i]),$cy+$r*sin($th is->angles[$i]),$cx+$r*cos($th is->angles[$i+1]),$cy+$r*sin($ this->angles[$i+1]),$this->web color);}}} is "cleaner" than this <?php function drawWeb() { $ang = 360/$this->numpts; $cx = $cy = $this->size/2; imagesetthickness($this->im, 1); for ($i=$this->firstAngle; $i <= 360; $i+=$ang) { $a = -deg2rad($i); $this->angles[] = $a; imageline($this->im, $cx, $cy, $cx+$this->radius1*cos($a), $cy+$this->radius1*sin($a), $this->webcolor); } $this->angles[] = -deg2rad($this->firstAngle); $rstep = $this->radius2/5; for ($r=$rstep; $r<=$this->radius2; $r+=$rstep) { for ($i=0; $i<$this->numpts; $i++) { imageline($this->im,$cx+$r*cos($this->angles[$i]), $cy+$r*sin($this->angles[$i]), $cx+$r*cos($this->angles[$i+1]), $cy+$r*sin($this->angles[$i+1]), $this->webcolor); } } } Link to comment https://forums.phpfreaks.com/topic/97343-new-lines-by-default/#findComment-498138 Share on other sites More sharing options...
random1 Posted March 23, 2008 Author Share Posted March 23, 2008 No Barand I'm not saying that. For far more characters. Maybe 40 characters across, just so that there is not horizonatal scrolling required in code. Link to comment https://forums.phpfreaks.com/topic/97343-new-lines-by-default/#findComment-498633 Share on other sites More sharing options...
wildteen88 Posted March 23, 2008 Share Posted March 23, 2008 What editor are you using to create your PHP scripts? Most PHP editors have a setting for showing a "Right margin" which will display a grey line up to x amount of characters so when you get up to right margin you can decide whether to carry on or go to the next line. If you are outputting very large strings then use the concatenation to split the string into multiple lines, eg: $str = 'Some very long string here. '. // split long string into multiple lines 'carry on very long string. '. 'and so on'; The above comes in handy with very long MySQL query's. Query's do not need to be defined in one continuous line. This will help to eliminate scrolling. Another example :- If you are defining an array which has a lot of items, I prefer to define each array item on a separate line, eg: $arr = array( 'item1', 'item2', 'item3', 'item4' => array( 'item4_a', 'item4_b', 'etc' ) ); You do not always have to code very long lines. Try to split them up in some way. Link to comment https://forums.phpfreaks.com/topic/97343-new-lines-by-default/#findComment-498748 Share on other sites More sharing options...
random1 Posted March 23, 2008 Author Share Posted March 23, 2008 Thanks I'll do that instead Link to comment https://forums.phpfreaks.com/topic/97343-new-lines-by-default/#findComment-499007 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.