PHP - Using self vs $this to access protected members from within a class? Say I have a protected method in PHP, as shown below:  class Test {      protected function hello($x) {         echo "hello " . $x . "&lt;br&gt;";     }      public function __construct() {         $i = 2;         self::hello($i);         $this::hello($i);     } }  $test = new Test();   The output is hello 2 printed twice. So calling the protected method hello works via both self and $this. Which is the correct approach? My personal answer is self, since $this refers to the current object, and any object of this class shouldn't have access to its protected method. Am I right or wrong?  Edit: This question isn't a duplicate. The other question talks only about accessing static members members through self and $this. I am interested in protected members specifically.
When to use self over $this? In PHP 5, what is the difference between using self and $this?  When is each appropriate?
Is there a way in javascript to detect if the unload event is caused via a refresh, the back button, or closing the browser? I am currently looking at the "unload" event of a window to try to determine how the "unload" event was triggered, but am having little success. Is there a way to determine how the javascript event was triggered?   Page Refresh Back Button (or navigate away from the page) Closing the Browser   Essentially I need to execute some code only when the browser window is being closed, not refreshed or navigated away from.  Purpose: When a customer does an update of our software, the update will redirect their first Internet request to an offer page. There is a button for a "Do Not Bother" option, but some users will simply close their browser. Upon closing the browser, I need to duplicate the "Do Not Bother" functionality so the user no longer gets redirected to the offer page. Simply attaching to the "unload" event will not work due to the different ways of leaving a page. How to put terms in lexicographic order? Induction Proof: Fibonacci Numbers Identity with Sum of Two Squares Using induction, how can I show the following identity about the fibonacci numbers? I'm having trouble with simplification when doing the induction step.  Identity: $$f_n^2 + f_{n+1}^2 = f_{2n+1}$$  I get to:  $$f_{n+1}^2 + f_{n+2}^2$$  Should I replace $f_{n+2}$ using the recursion? When I do that, I end up with the product of terms, and that just doesn't seem right. Any guidance on how to get manipulate during the induction step?  Thanks! While editing some ad copy, and I was given the sentence, "Defending a lawsuit can be a big cost for your business." (My italics.)  I keep thinking the proper word to use is "expense" rather than "cost" as in: "Defending a lawsuit can be a big expense for your business." But I'm just not sure I'm correct.   Can anyone help with more definitive guidance? Can "cost" and "expense" be used interchangeably in a sentence like this?   Thank you! I am trying to understand what mathematics is really built up of. I thought mathematical logic was the foundation of everything. But from reading a book in mathematical logic, they use "="(equals-sign), functions and relations.  Now is the "=" taken as undefined? I have seen it been defined in terms of the identity relation.  But in order to talk about functions and relations you need set theory.  However,  seems to be a part of mathematical logic.  Does this mean that (naive) set theory comes before sentential and predicate logic? Is (naive)set-theory at the absolute bottom, where we can define relations and functions and the eqality relation. And then comes sentential logic, and then predicate logic?  I am a little confused because when I took an introductory course, we had a little logic before set-theory. But now I see in another book on introduction to proofs that set-theory is in a chapter before logic. So what is at the bottom/start of mathematics, logic or set theory?, or is it circular at the bottom?  Can this be how it is at the bottom?  naive set-theory $\rightarrow$ sentential logic $\rightarrow $ predicate logic $\rightarrow$ axiomatic set-theory(ZFC) $\rightarrow$ mathematics  (But the problem with this explanation is that it seems that some naive-set theory proofs use logic...)  (The arrows are of course not "logical" arrows.)  simple explanation of the problem:  a book on logic uses at the start: functions, relations, sets, ordered pairs, "="  a book on set theory uses at the start: logical deductions like this: "$B \subseteq A$", means every element in B is in A, so if $C \subseteq B, B \subseteq A$, a proof can be "since every element in C is in B, and every element in B is in A, every element of C is in A: $C \subseteq A$". But this is first order logic? ($(c \rightarrow b \wedge b \rightarrow a)\rightarrow (c\rightarrow a)$).  Hence, both started from each other? Intuition behind the definition of a measurable set "BookList" or "booksList?" Possible Duplicates:             I'm wondering whether or not I should use a plural form noun with a collection name. For example, which one is correct, bookList or booksList (obviously they are variables in a programming language)? I just picked up a copy of Windows 7 Pro OEM for install on my computer.  Guy at the store said the only real difference between OEM and standard retail box was tech support.  However, the outside of the box has this big warning that says "The software must be installed with an OPK"?  What is the OPK?  Is it really necessary?  The MS site about it seemed to say it was optional.  EDIT:  BTW - I'm just an individual tinkerer, and not a System Builder Company Employee.  I should have made that clear.  I've used sysprep in a professional setting in the past, so I'm somewhat familiar with its concepts. What determines how much experience I get from a hearthstone match in play mode? Sometimes I win handily and get a little experience, sometimes I squeak out a victory and get a lot.  How is experience earned? I use the babel package in order to write in greek with font "kerkis".  I want to add code in english ("courier new" font) to my latex document but I get some difficulties.  Can anybody help me, please. Thank you in advance.  \documentclass[12pt]{article} \usepackage[english,greek]{babel} \usepackage[utf8x]{inputenc} \usepackage{graphicx} \usepackage{fancybox} \usepackage{verbatim} \usepackage{courier} \usepackage{kerkis} \usepackage{float} \usepackage{geometry} \usepackage{fancyhdr} \usepackage{titlesec} \usepackage{tocloft} \usepackage{hyperref} \usepackage{afterpage} \usepackage{color}    \usepackage{listings}  \renewcommand{\lstlistingname}{Κώδικας}  \lstset{  %matlab   backgroundcolor=\color{white},     basicstyle=\normalsize,    % COURIER NEW?        commentstyle=\color{green},    % comment style   escapeinside={\%*}{*)},           extendedchars=true,               frame=single,                              keywordstyle=\color{blue},       % keyword style   numbers=left,                     numbersep=5pt,                     numberstyle=\normalsize\color{black},    rulecolor=\color{black},           stepnumber=1,                      stringstyle=\color{magenta},     % string style }   \begin{document}  \selectlanguage{greek} Ελληνικά: \textlatin{this word means greek}  \selectlanguage{english} Now I write in english  \selectlanguage{greek} Ελληνικά  %\selectlanguage{english}???  \begin{lstlisting}[caption = \textlatin{example1.m}] { % Entropy E = 0; for i = 1:J     if p(i) ~= 0         E = E + p(i)*log2(1/p(i));     end end } \end{lstlisting}  \end{document} There are many, many old posts on meta asking for suggestions on how to better organize favorites.  ,  and , among others.  This is not meant to be an open discussion on how to improve favorites, but rather a specific feature request that I'd like feedback on.      I would love to see a feature added that would let users arbitrarily create "groups" of favorites, and drag individual favorited questions under these groups.  I have about 2 pages of favorites (I know others have much more), and finding an individual one is quite difficult, especially since the specific question title is usually forgotten.  I just added  to my favorites, since I liked Andrew Whitaker's answer, and might want to come back and look at it later; I'd love to add this to a group called, say, "Useful Code".    I've favorited other posts since they had neat tricks in them, or because there were answers written on interesting theoretical computer science topics.  Having different groups for all these areas would be immensely helpful in finding posts later. I've been playing the game a while now and have ranked up considerably. I'm wondering if there is any way to change to a different Google account and still keep all of my Pokemon/items etc, as I stupidly used my university gmail account when I first downloaded the app (which will be automatically deleted in September).   Is there any way to transfer my trainer/Pokemon/items etc to a different Google account? What is the best way to save values (like strings) for later use? I'm fairly new to LaTeX and I'm struggling with something apparently simple, but for which I can't find a fair solution. The problem (simplified) is as follows (please take care terms used may not have the traditional meaning in LaTeX):  I need to references to files (many) throughout a text. As example, the files:  "C:/Work/this_file1.c", "C:/MoreWork/this_file1.c" and "D:/MoreWork/another_file2.h".  So, now I would like to create an "alias" to each directory and each name file so I can reference them. A "pseudocode" could be:  % Definition \alias \c_dir = C:/Work/ \alias \d_dir = D:/MoreWork/ \alias \file1 = this_file1.c \alias \file2 = another_file2.h  % Reference in text \c_dir\file1    % For referencing C:/Work/this_file1.c \d_dir\file1    % For referencing D:/MoreWork/this_file1.c \c_dir\file2    % For referencing C:/Work/another_file2.h   My first approach was using \newcommand, but that caused numerous problems due to naming limitations. (I also tried other methods like pgfkeys, but it always gets stuck somewhere!)  Can you suggest a method? That is, what are some good examples of vector spaces which are inner product spaces but in which not every Cauchy sequence converges? How can I obfuscate (protect) JavaScript? Which Ubuntu to use alongside Windows 7? Is it possible to trade Pokemon from the 1st generation games to the most recent ones? I know that you can trade Pokemon between games of the same generation (Gold/Silver, Ruby/Sapphire) and even trade between 1st gen and 2nd gen. However, I haven't been able to find a way to trade Pokemon so that I can play with my 1st generation Pokemon in HeartGold, for instance. If it is possible, how many steps would it take and what equipment would I need? It didn't fixed the error. So, how do I fix my GUI update?  For every software I have to install it from command line because I got same error when install software from Ubuntu Software Center. Which loss function is correct for logistic regression? I read about two versions of the loss function for logistic regression, which of them is correct and why?  From  (in Chinese), with $\beta = (w, b)\text{ and }\beta^Tx=w^Tx +b$: $$l(\beta) = \sum\limits_{i=1}^{m}\Big(-y_i\beta^Tx_i+\ln(1+e^{\beta^Tx_i})\Big)  \tag 1$$  From my college course, with $z_i = y_if(x_i)=y_i(w^Tx_i + b)$: $$L(z_i)=\log(1+e^{-z_i}) \tag 2$$    I know that the first one is an accumulation of all samples and the second one is for a single sample, but I am more curious about the difference in the form of two loss functions. Somehow I have a feeling that they are equivalent. If $f,g:X \to Y$ are continuous and $Y$ is $T_2$, then $\{x \in X\,|\,f(x)=g(x)\}$ is closed I'd like to know if the following proof is valid.  The only thing I'm not sure about (though I can't see why it's invalid if it is) is if we can always use the Hausdorfness of $Y$ to separate an open set from $f(C)=g(C)$.  "Let $X$ be a space, $Y$ a $T_2$-space, and $f,g:X \to Y$ continuous functions.  Prove that $C:=\{x \in \,|\,f(x)=g(x)\}$ is a closed subset of $X$."  Let $x \in X$ be such that $f(x) \ne g(x)$.  Since $Y$ is $T_2$, there are open sets $U_\alpha \ni f(x)$ and $V_\alpha \ni g(x)$ such that $U_\alpha \cap O_\alpha=V_\alpha \cap O_\alpha=\varnothing$ for all $\alpha \in A$ where $A$ is the set indexing the points of $f(C)=g(C)$, and $O_\alpha$ is an open set containing $x_\alpha \in f(C)=g(C)$.  Let $U:=\displaystyle\bigcap_{\alpha \in A} U_\alpha$ and $V:=\displaystyle\bigcap_{\alpha \in A} V_\alpha$.  Then $U \cap f(C)=V \cap f(C)=\varnothing$.  Therefore, since $f,g$ are continuous, $f^{-1}(U)$ and $g^{-1}(V)$ are open sets in $X$ disjoint from $C$.  Since $X\setminus A$ is the union of such open sets, it is open itself and therefore $C$ is closed.  Thanks.