I'm moving my project from Zend Studio 5 to 9.
Zend 9 ruins my indentation. Previously my code was formatted to have a tab be two spaces. Now Zend is using four spaces and some lines are indented further than before.
Before:
$a=1;
$b=1;
$c=1;
for ($i=0; $i<10; $i++)
{
echo "test";
}
Now
$a=1;
$b=1;
$c=1;
for ($i=0; $i<10; $i++)
{
echo "test";
}
I've tried setting the tab policy to "spaces" and the indentation size to "2". But that doesn't work.
I fixed it by setting Displayed tab width to "2".
This is on the page: General > Editors > Text Editors
Related
Anyone knows how to avoid firefox console to group log entries?
I have seen how to do it with firebug https://superuser.com/questions/645691/does-firebug-not-always-duplicate-repeated-identical-console-logs/646009#646009 but I haven't found any group log entry in about:config section.
I don't want use Firebug, because it's no longer supported or maintained and I really like firefox console.
I try to explain better, I want console to print all logs and not the red badge with number of occurences of one log string:
In the above picture I would like to have two rows of the first log row, two rows of the second and three of the third.
Is this possible?
Thanks in advance
Update [2022-01-24]
Seems like the below option doesn't work as expected. feel free to report it as a bug
Update [2020-01-28]
Firefox team added option to group similar messages, which is enabled by default.
You can access to this option via Console settings
Open up Firefox's dev tools
Select Console tab
Click on gear button (placed at the right of the toolbar)
Change the option as you wish
Original Answer
As I mentioned in comment section, There is no way to achieve this at the moment. maybe you should try to request this feature via Bugzilla#Mozilla
Also you can check Gaps between Firebug and the Firefox DevTools
As a workaround you can append a Math.random() to the log string. That should make all your output messages unique, which would cause them all to be printed. For example:
console.log(yourvariable+" "+Math.random());
There is a settings menu () at the right of the Web Console's toolbar now which contains ✓ Group Similar Messages:
To solve this for any browser, you could use this workaround: Override the console.log command in window to make every subsequent line distinct from the previous line.
This includes toggling between prepending an invisible zero-width whitespace, prepending a timestamp, prepending a linenumber. See below for a few examples:
(function()
{
var prefixconsole = function(key, fnc)
{
var c = window.console[key], i = 0;
window.console[key] = function(str){c.call(window.console, fnc(i++) + str);};
};
// zero padding for linenumber
var pad = function(s, n, c){s=s+'';while(s.length<n){s=c+s;}return s;};
// just choose any of these, or make your own:
var whitespace = function(i){return i%2 ? '\u200B' : ''};
var linenumber = function(i){return pad(i, 6, '0') + ' ';};
var timestamp = function(){return new Date().toISOString() + ' ';};
// apply custom console (maybe also add warn, error, info)
prefixconsole('log', whitespace); // or linenumber, timestamp, etc
})();
Be careful when you copy a log message with a zero-width whitespace.
Although you still cannot do this (as of August of 2018), I have a work-around that may or may not be to your liking.
You have to display something different/unique to a line in the console to avoid the little number and get an individual line.
I am debugging some JavaScript.
I was getting "Return false" with the little blue 3 in the console indicating three false results in a row. (I was not displaying the "true" results.)
I wanted to see all of the three "false" messages in case I was going to do a lot more testing.
I found that, if I inserted another console.log statement that displays something different each time (in my case, I just displayed the input data since it was relatively short), then I would get separate lines for each "Return false" instead of one with the little 3.
So, in the code below, if you uncomment this: "console.log(data);", you will get the data, followed by " Return false" instead of just "false" once with the little 3.
Another option, if you don't want the extra line in the console, is to include both statements in one: "console.log("Return false -- " + data);"
function(data){
...more code here...
// console.log(data);
console.log("Return false ");
return false;
}
threeWords("Hello World hello"); //== True
threeWords("He is 123 man"); //== False
threeWords("1 2 3 4"); //== False
threeWords("bla bla bla bla"); //== True
threeWords("Hi"); // == False
I am using an if statement and trying to get one of two statements to show, depending on the session running.
please help. thank you.
if (session_name== "admin"){
echo ("[Admin Logout]");
}else {
echo "[Member Logout]";
}
?>
Also there is 2 syntax errors on the echo parts.
You if you use double quotes around the argument to echo, you should use single quotes inside it for the HTML attribute, or vice versa (an alternative is to escape the inner quotes with backslash, but I never understand why people prefer this). And you need $ before the variable name.
if ($session_name== "admin"){
echo ("<a href='admin/logout.php'>[Admin Logout]</a>");
}else {
echo "<a href='logout.php'>[Member Logout]</a>";
}
I have been trying to crawl a website pages and search for specific text using simple html dom and XPath. I have get all the links from website and trying to crawl that links and search text on all pages. The text that i want to search is within html span tag.
But no output is shown.
whats going wrong ?
here is my code
<?php
include_once("simple_html_dom.php");
set_time_limit(0);
$path='http://www.barringtonsports.com';
$html = file_get_contents($path);
$dom = new DOMDocument();
#$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$hrefs = $xpath->evaluate("/html/body//a");
for($i = 0; $i < $hrefs->length; $i++ ){
$href = $hrefs->item($i);
$url = $href->getAttribute('href');
$nurl = $path.$url;
$html1 = file_get_contents($nurl);
$dom1 = new DOMDocument();
#$dom1->loadHTML($html1);
$xpath1 = new DOMXPath($dom1);
$name = $xpath1->evaluate("//span[contains(.,'Asics Gel Netburner 15 Netball Shoes')]");
if($name)
echo"text found";
}
?>
I just want to check the whether text "Asics Gel Netburner 15 Netball Shoes" exist in any page of the website www.barringtonsports.com or not.
You're querying a lot of web-pages interactively. It takes more time than your server is allowed to use for generating pages.
You can execute this script from command-line to avoid timeouts or you can try to configure PHP and WebServer so they give more time to the script (you can ask on https://serverfault.com/ how to do this)
Well, first off you are mixing Simple HTML DOM and DOM Document. Just use one or the other. Since this is in the simple-html-dom tag start with this from the command line:
<?php
require_once("./simple_html_dom.php"); # simplehtmldom.sourceforge.net to use manual
$path="http://www.barringtonsports.com";
$html = file_get_html($path);
foreach ($html->find('a') as $anchor) {
$url = $anchor->href;
echo "Found link to " . $url . "\n";
# now see if the link is relative, absolute, or even on another site...
$checkhtml = file_get_html($url);
# now you can parse that link for stuff too.
}
?>
But really, that website has a search form, why not just send it a query instead and read the results?
I'm writing my own component for Joomla 1.5. I'm trying to figure out how to generate an "alias" (friendly URL slug) for the content I add. In other words, if the title is "The article title", Joomla would use the-article-title by default (you can edit it if you like).
Is there a built-in Joomla function that will do this for me?
Line 123 of libraries/joomla/database/table/content.php implements JFilterOutput::stringURLSafe(). Pass in the string you want to make "alias friendly" and it will return what you need.
If you are trying to generate an alias for your created component it is very simple. Suppose you have click on save or apply button in your created component or suppose you want to make alias through your tile, then use this function:
$ailias=JFilterOutput::stringURLSafe($_POST['title']);
Now you can insert it into database.
It's simple PHP.
Here is the function from Joomla 1.5 source:
Notice, I have commented the two lines out. You can call the function like
$new_alias = stringURLSafe($your_title);
function stringURLSafe($string)
{
//remove any '-' from the string they will be used as concatonater
$str = str_replace('-', ' ', $string);
$str = str_replace('_', ' ', $string);
//$lang =& JFactory::getLanguage();
//$str = $lang->transliterate($str);
// remove any duplicate whitespace, and ensure all characters are alphanumeric
$str = preg_replace(array('/\s+/','/[^A-Za-z0-9\-]/'), array('-',''), $str);
// lowercase and trim
$str = trim(strtolower($str));
return $str;
}
I'm using Visual Studio 2005. It always wants to format switch statements like this:
switch (thing)
{
case A:
stuff;
break;
case B:
things;
break;
}
Is there a way to have it indent the cases like this?:
switch (thing)
{
case A:
stuff;
break;
case B:
things;
break;
}
Go here:
Tools > Options > Text Editor > C# > Formatting > Indentation > Indent case labels
An updated method of doing this, it's not too different.
Tools > Options > Text Editor > (Language) > Code Style > Formatting > Indentation > Indent case labels
Tools | Options | Text Editor | c# -> check 'Ident block contents' checkbox.