is this the way to get the screen height and width? no built-in functions?
PHP is server-side, there is absolutely no way that PHP ALONE can get the screen width and height.
That method uses Javascript to POST to a PHP page, which will work, yes.