Best PHP IDE’s Windows/Linux and Mac OS

Sublime Text 3

The lightweight and very popular text editor supports a lot of programming languages. You can use a free version or buy a license for 80$. I think it’s a must to have editor and successfully replacing Notapad++. Responsiveness and speed is a very big advantage when you have limited ram/cpu. If out of box functionality is not for enough you can search and install packages

Visual Code
Created by Microsoft, Open Source free IDE, VS Code supports many programming languages and is lightweight enough to work on slow computers. It’s one of the best editors for JavaScript/Typescript but you will need to install extension to make it work well with PHP.

Netbeans
Created by Apache Software Foundation it’s free and open-sourced. Great out of box PHP support, greate autocomplete function, for professional PHP programmer it should be great IDE but uses a lot of resources, it can be slow and not very responsive on a slow computer.

PHPStorm
Costs 199$ the first year and also have free trails for 30 days. Considered as BEST PHP ide! It’s heavier then VS Code & sublime but it’s much more powerful than any other in this list. No matter on which PHP project you work, it feels like Phpstorm just understands your project and helping you to do things much faster. The only downside is price but if you can afford it, it’s best.

PHP Script To Send Email Using SMTP

It’s very easy to send email using PHP via SMTP, first of all you must downloads PHP Mailer (https://github.com/PHPMailer/PHPMailer), after we will use small script as an example which will connect to smtp and send email.

<?php
 
require_once "PHPMailer-master/PHPMailerAutoload.php";
 
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "mail.domain.com";
$mail->SMTPAuth = true;
$mail->Username = "username";
$mail->Password = "password";
$mail->From = "[email protected]";
$mail->FromName = "Your Name";
$mail->AddAddress("[email protected]");
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = "This is subject";
$mail->Body = "THis is body <b>html</b>";
$mail->AltBody = "This is the body in plain text.";
if (!$mail->Send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}

Beautify XML to print in C#

You can print XML normally but it will not be formatted, we have solution which can help you to output XML in nice format We will use XmlTextWriter function to do this here is simple function which you can use in project.

public static String BeutyXML(String XML)
        {
            String Result = "";
 
            MemoryStream mStream = new MemoryStream();
            XmlTextWriter writer = new XmlTextWriter(mStream, Encoding.Unicode);
            XmlDocument document = new XmlDocument();
 
            try
            {                
                document.LoadXml(XML);
                writer.Formatting = Formatting.Indented;
 
                document.WriteContentTo(writer);
                writer.Flush();
                mStream.Flush();
 
                mStream.Position = 0;
 
                StreamReader sReader = new StreamReader(mStream);
                String FormattedXML = sReader.ReadToEnd();
 
                Result = FormattedXML;
            }
            catch (XmlException)
            {
            }
 
            mStream.Close();
            writer.Close();
            
            // Return formatted XML
            return Result;
        }

you can call it with simple command

textBox2.Text = BeutyXML(payout.Getsoapresponse());

That’s all!

Simple Code To Read CSV file – JAVA

it’s very simple to read CSV and then get all information by columns this is simple code which will help you with it

try {
BufferedReader br = new BufferedReader(new FileReader("./customer-list.csv"));
  while ((line = br.readLine()) != null) {
   if (!line.isEmpty()) {
    // use comma as separator
    String[] data = line.split(",");
    //data[0] contains first column if you want second one use data[1] and so on
    System.out.println(data[0]);
}
}
 
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

Skip First line with FileReader – Java

Example how to skip first line of any file which you want to read using FileReader in Java

        BufferedReader br = new BufferedReader(new FileReader("./test.csv"));
 
        br.readLine();
        while ((line = br.readLine()) != null) {
            if (!line.isEmpty()) {
                // use comma as separator
                String[] data = line.split(",");
            }
        }

all what we are doing is adding br.readLine(); before while loop this will read first line so it will be skipped in loop.

MySQL fetching the first row instead of all

This problem normally occurs when your forgetting to place array into container, for example PHP

$query = mysql_query( "SELECT * FROM `table`" );
$getrows = mysql_fetch_assoc( $query );
 
foreach ( $getrows as $row ) {
echo $row['id'];
}

We will have in this situation only first row not others, to get all rows we must use while() loop PHP

$query = $db->query( "SELECT * FROM `matches`" );
while ( $rows = mysql_fetch_array( $query ) ) {
echo rows['id'];
}

using while loop your getting all rows you can save them into array and so on.