I want to create a YML file using php and write text in it so that it can be used in symfony. But I didn't found any helping link or material from which I can start. Also is their any difference in YML and YAML file?
To use YAML files you need to download Yaml component from Symfony framework. For example by executing
composer require symfony/yaml
or by downloading it from github
If you choose composer remember to include vendor/autoload.php into your project.
You can find a lot of information how to start with yaml on Symfony Page that describes the component, including creation and manipulation of files.
Yml is just an extension for Yaml files.