Neither is "better". They are BOTH completely and entirely different to each other.
PHP is server-side code
javascript is client-side code
And depending on what you call 'dynamic' you will probably need both, along with HTML, CSS and some SQL code
Thirdly;
You cannot 'build' a website using PHP and/or javascript, a 'website' is a collection of HTML documents, you can create the HTML documents using PHP code, and you can alter the pages "on the fly" (dynamically) with javascript, but javascript needs the HTML document structure to exist first.