How to detect Safari browser

PHP, JS: How to detect Safari browser

PHP Example: Result: Javascript Recent search terms:https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1887 OvgUxpr9qO2nSY7xfBBfqrMyKKrUz4ZjLCjLo80gRf5IrfuQNKFPcR5BNsfVUgiM 7aaec94f496207709c48efc5ef2ebb32c8e11a85&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme