Asked  2 Years ago    Answers:  5   Viewed   110 times

I need to get the path from the URL of the current request. For example, if the current URL is:


I would want this:




You want $_SERVER['REQUEST_URI']. From the docs:


The URI which was given in order to access this page; for instance, '/index.html'.

Thursday, November 10, 2022

Try this:

$str = ' file [that] needs "to" be (encoded).zip';
$pos = strrpos($str, '/') + 1;
$result = substr($str, 0, $pos) . urlencode(substr($str, $pos));

You're looking for the last occurrence of the slash sign. The part before it is ok so just copy that. And urlencode the rest.

Thursday, November 3, 2022

According to the PHP manual, you must specifically encode a URL if it contains special characters. This means the function itself should do no special encoding. Most likely your URL is being encoded before being passed to the function, so pass it through urldecode first and see what happens.

Edit: You're saying the encoding is being messed up. Again the PHP manual specifically states that you need to encode urls prior to passing them to file_get_contents. Try encoding the URL, then passing it to the function.

$url = urlencode($url);
Thursday, September 22, 2022

According to the docs (emphasis mine):

You can use groovyScript macro with multiple arguments. The first argument is a script text that is executed or a path to the file that contains a script. The next arguments are bound to _1, _2, _3, ..._n variables that are available inside your script. Also, _editor variable is available inside the script. This variable is bound to the current editor.

The _editor is an instance of EditorImpl which holds a reference to the VirtualFile that represents the currently opened file.

Therefore, the following script gets the full path of currently opened file.


Or if you want to get the path relative to the project's root:

groovyScript("_editor.getVirtualFile().getPath().replace(_editor.getProject().getBaseDir().getPath(), "")")
Saturday, December 10, 2022

You can, current->pid exists and is the process that was interrupted (may be the idle thread, or any).

If you're writing inside the Linux scheduler, you should be very careful. current is changed by the scheduler as it chooses a new process to run, so its value depends on when exactly you read it.

Tuesday, November 1, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :

Browse Other Code Languages