Postgresql script to createdb - Help

Hello

I am new to Postgresql.

I’m trying to write a simple script to create a database using variables for the user and password.

Something like in php: Variables $user, $password and $database

createdb $user $password -W --encoding=utf8 $database

Can someone tell me the correct syntax for this to work.

Thank you