How to add comments in PHP Eclipse? - php

How can I add comments in PHP eclipse? I'm trying by selecting few lines of code, then right click, On menu, "Source" and then I have tried all these options there "general element comment", "toggle comment", "Add block comment". None of them works.
PS. I just downloaded latest eclipse PHP version.

Try Ctrl+Shift+/
The question is similair to How to comment a block in Eclipse?

Why don't you just try adding /** + enter? It will produce something like
/**
* Comment here
*/
Remember to follow the doc order
/**
* Description
* #param argument/parameter
* #return
*/

It`s a bug in latest PHP eclipse. Fix is here.

I was using single line comments on my eclipse php project. When i uploaded it to server ,some obfuscation has been applied automatically.Hence all the line breaks are removed and it treating the whole program as a single line. so i am getting an END OF STATEMENT error on server.So its better to use /--/ instead of //---- while commenting.

Related

Prevent VSCode auto add empty newline after <?php, and before comments

When I write in a php file the following:
<?php
/**
* Comments....
the VSCode autoformat on save like this:
<?php
/**
* Comments....
I don't want this auto empty newline.
The "problem" is detected only after the combination of <?php and /** comments.
Thank you
not sure how to really say this in a completely understandable way, but you need to edit the formatter configuration that you use in vscodes settings. Or you can install a different formatter and use that instead with its own config

Automatic add / update comment header block in source files

I can't believe that I didn't find an already asked question to that topic (maybe I am wrong). However, for example in WordPress-Themes all PHP-files come with a comment header block:
<?php
/**
* Template for header
*
* Description
*
* #Author: Mokorana
* #Date: 2020-11-26 09:19:12
* #Last Modified by: Mokorana
* #Last Modified time: 2020-11-27 10:08:51
*
* #package mokorana
*/
?>
Whats is the best practice to add and maintain these comment blocks? Is it done directly in the text editor (atom) or in a node-workflow or however?
Adding header comments it's usually automated process.
The simplest way is to configure header comment for each new PHP file in your IDE. For example PhpStorm has File templates for this.
Another option these are tools like PHP CS Fixer. You configure header comment template and add it to all files in your project using one simple command.
Tools like PHP CS Fixer it's a better way, because if you want to change something in your comment, you just need to update template in config file and run console command again. It will update all files in your project.

Code folding in Notepad++ for PHP

I'm using Notepad++ 6.6.9. In Java I'm able to use code folding as simple as this:
//{ region 1
public Core(){}
//}
I don't even need to save. Just add this sort of code and collapsable itens are added around it.
But in PHP I can't make it work. I've tried the following:
//{#region LOADING
//{START LOADING
//{ region 1
//}
//}END example
//}#endregion LOADING
It simply doesn't work. Could somebody point me any working code, or a tutorial on how to configuring some custom one?
See here: https://stackoverflow.com/a/25954860/3869072
I just looked for the same, so you can simply write this:
#region LOADING
//Your code here
#endregion LOADING
the # works obviously as a comment in php

how i can modify the style block comment in sublime text

the form of comment block for php in sublime-text looks like this.
 
/ * Example * /
I would like to change it to look like that.
/**
* example
**/
I try to modify the file in Comments.tmPreferences Package / php / but I'm not coming. I do not understand the xml use.
I know it is not much, but just personal choice.
Use sublime-jsdocs
install the package, and you should be able to make docblock comments.
By Pressing enter or tab after /** (or ###* for Coffee-Script) will yield a new line and will close the comment.
With Package Control installed, you can install DocBlockr from inside Sublime Text itself. Open the Command Palette and select "Package Control: Install Package", then search for DocBlockr and you're done!
you can do this:
(Docblock completion)
(Comment extension)
or this:

How to attach php documentation in eclipse

Is there any way to attach PHP docs in eclipse, so that if I hover over any function I could get all the details and the related description.
Something on similar lines to javadocs.
Using:
Eclipse: helios
php5.
OS: Ubuntu 12.04
Here is step for configure PhpDoc into eclipse :
1. Open eclipse IDE
2. Then select Window Menu & Select Preferences
3. Then navigate through php menual
4. After Cliking on New You will get this Window :
Here specify latest .chm File Give Name and Press Ok.
5. Set it to default & press Ok [ It will display in bold letter]
6. After Setting it to default you will get your local help will highlighted with bold letter
7. When you want to see doc for php function then press Shift + F2
Note : You can also change help option from Window -> Preferences
You can try:
Create a new PHP Project (File->New->PHP Project)
Switch to the PHP perspective (Window->Open Perspective->PHP)
Create a PHP file
If you now write something like
<?php phpinfo(); ?>
and hold your mouse over "phpinfo" you should get a popup with the information.
Hold CTRL to jump directly into it.
If you want to documentate your own code use the following:
/**
* Some text here
* #param string $str input
* #param array $arr data
* #return boolean
*/
hope that will help you.
Cheers

Categories