1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Reformatting php code

Discussion in 'PHP' started by SGBoise, Dec 11, 2008.

  1. #1
    Hey Guys,

    Anyone know of any software for reformatting php code.

    I want to convert:
    	if(!isset($_SESSION["language"]) || $_SESSION["language"]=="")
    	{	
    		$_SESSION["language"]="English";
    		$language="English";
    	}
    	else
    	{
    		$language=$_SESSION["language"];
    	}
    PHP:
    to
    	if(!isset($_SESSION["language"]) || $_SESSION["language"]=="") {	
    		$_SESSION["language"]="English";
    		$language="English";
    	} else {
    		$language=$_SESSION["language"];
    	}
    PHP:
     
    SGBoise, Dec 11, 2008 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    You can use a text editor and find and replace to get the correct formatting. Dreamweaver has a good, multi-line find and replace function.

    Is there any specific reason you want to do this? The first example is more accepted as the correct way to format code.
     
    jestep, Dec 12, 2008 IP
    SGBoise likes this.
  3. farad

    farad Peon

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Software - keyboard driver .. :D
    Press BACKSPACE or TAB to edit your code .. there is no need for a special software !

    Ahh, anyway .. you can use : MS FrontPage, Notepad++, Dreamviewer, etc.
     
    farad, Dec 12, 2008 IP
  4. SGBoise

    SGBoise Peon

    Messages:
    647
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks for the replies. I find it a lot easier to read the code my way and takes up less lines. Just a personal preference.

    I'll try the multi line search a try.
     
    SGBoise, Dec 12, 2008 IP
  5. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #5
    Nah, use a program with a built-in beautifier... I use phpDesigner and Zend Studio personally, and of the two I would say Zend has the more powerful beautifier, I use it for literally every piece of code I write. Vital tool for any professional.
     
    Danltn, Dec 14, 2008 IP
    SGBoise likes this.
  6. svimalkumar_mca

    svimalkumar_mca Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    just use the function import_request_variables() to avoid the isset().
    the posted value will automatically come to php part while submitting the form....
     
    svimalkumar_mca, Dec 15, 2008 IP