Use $this to refer to the current object. Use self to refer to the current class. In other words, use $this->member for non-static members, use self::$member for static members.
Source: When to use self vs this -stackoverflow
| <?php | |
| // generate private/public key as follows: | |
| // > openssl genrsa -out private.pem 2048 | |
| // > openssl rsa -in private.pem -outform PEM -pubout -out public.pem | |
| $data = "String to encrypt"; | |
| $privKey = openssl_pkey_get_private('file:///path/to/private.pem'); | |
| $encryptedData = ""; |
| <?php | |
| function encrypt_mcrypt($msg, $key, $iv = null) { | |
| $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC); | |
| if (!$iv) { | |
| $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); | |
| } | |
| $pad = $iv_size - (strlen($msg) % $iv_size); | |
| $msg .= str_repeat(chr($pad), $pad); | |
| $encryptedMessage = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $msg, MCRYPT_MODE_CBC, $iv); | |
| return base64_encode($iv . $encryptedMessage); |
| //import the selenium web driver | |
| var webdriver = require('selenium-webdriver'); | |
| var chromeCapabilities = webdriver.Capabilities.chrome(); | |
| //setting chrome options to start the browser fully maximized | |
| var chromeOptions = { | |
| 'args': ['--test-type', '--start-maximized'] | |
| }; | |
| chromeCapabilities.set('chromeOptions', chromeOptions); | |
| var driver = new webdriver.Builder().withCapabilities(chromeCapabilities).build(); |
Use $this to refer to the current object. Use self to refer to the current class. In other words, use $this->member for non-static members, use self::$member for static members.
Source: When to use self vs this -stackoverflow