Skip to content

Cannot add child to XML node in PHP

I am trying to add a child note to an XML file using PHP. I have used the same method about 5 times before and each one works as expected, however this method is using a different XML structure on a …

A __construct on an Eloquent Laravel Model

I have a custom setter that I’m running in a __construct method on my model. This is the property I’m wanting to set. protected $directory; My Constructor public function __construct() …

phpseclib loadKey works on mac, not on CentOS

I am attempting to load a hardcoded (for the sake of testing) RSA public key in phpseclib (stable version 0.3.10). This code works perfectly correctly when run locally on my Mac and spits back out the key I entered: However when I push it to an AWS instance running CentOS, the loadKey call returns false. I&#8…

Get primary key of Eloquent model instance

I’m happy enough to work on a project with (not) very consistent column names in our MySQL database. We have camelCase, PascalCase, ‘Id’, ID and it’s driving me nuts. I’ve decided to start using Eloquent in our application (which is NOT Laravel). I would love to have a method of …

Sanitize & desanitize multidimensional array

I have the following class I wrote: The problem is that while it works on strings and one-dimensional arrays, I get the following error with multidimensional arrays: Warning: htmlspecialchars() expects parameter 1 to be string, array given in C:wampwwwclassesSanitizer.php on line 10 How do I fix this? Any hel…