Skip to content

Instantly share code, notes, and snippets.

@shtrom
Last active September 5, 2022 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shtrom/b98252b215346c625a449010c10a2b4f to your computer and use it in GitHub Desktop.
Save shtrom/b98252b215346c625a449010c10a2b4f to your computer and use it in GitHub Desktop.
`static` vs `self`
<?php
class VarHolder {
const VAR = 2;
public function showVar() {
echo self::VAR;
echo static::VAR;
}
}
<?php
class ChildVarHolder extends VarHolder {
const VAR = 4;
public function doSomething() {
echo self::VAR;
echo static::VAR;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment