Properly Label Author and Project name in PHP Files?

316 views Asked by At

I simply wanted to know what is the most accepted way to credit yourself and describe the overall package in (preferably) the beginning of the document so other individuals viewing the code have a reference?

I would like to know the answer because of a PHP project I am working on and I believe when it is done people will view the source code. I currently have a // comment in the beginning but it seems lacking. I have seen people use block comments and add a @author and so forth, is this the accepted syntax?

Thanks.

2

There are 2 answers

0
Niels Keurentjes On BEST ANSWER

Yes, the syntax with block comments and tags like @author and @copyright is standardized, it's called PHPDoc.

You can find a good starting reference here.

The main advantage of using this standardized way of markup for code metadata is that you can then use standardized tools like PHPDocumentor to automatically generate documentation like this. Another is that advanced IDEs like PHPStorm can parse the docblocks to provide autocomplete and other code completion functionality, and even smart refactoring tools.

0
Sohail Ahmed On

You can use this style it is called PHPDoc style.

/**
 *  return string of content between provided
 *  $from and $to positions.
 *  if $to is not provided $from will be considered              
 *  a string to remove.
 *
 * @param string $str string from select contents
 * @param string $from starting point for select contents
 * @param string $to ending point for select contents * 
 * @return string
 * @author 
 */
 function extractor($str,$from,$to)
 {
    $from_pos = strpos($str,$from);
    $from_pos = $from_pos + strlen($from);
    $to_pos   = strpos($str,$to,$from_pos);// to must be after from
    $return   = substr($str,$from_pos,$to_pos-$from_pos);
    unset($str,$from,$to,$from_pos,$to_pos );           
    return $return;

 }