I have some doubts regarding how to implement child theme

In https://codex.wordpress.org/Child_Themes they have given 2 different enqueue codes, what’s the difference between them?

This is the first one

<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );

}
?>

This is the second one

<?php
function my_theme_enqueue_styles() {

    $parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.

    wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style',
        get_stylesheet_directory_uri() . '/style.css',
        array( $parent_style ),
        wp_get_theme()->get('Version')
    );
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>

Whats the difference between the two and which one should be used and would this code work across all the wordpress themes ?

Second doubt I have is about a rtl.css file. I have this file name rtl.css in my theme.
Do I need to enqueue rtl.css too using

 wp_enqueue_style( $parent_style, get_template_directory_uri() . '/rtl.css' );

After adding rtl.css in the child theme directory

To support RTL languages, add rtl.css file to your child theme, containing:

/*
Theme Name: Twenty Fourteen Child
Template: twentyfourteen
*/

Solutions Collecting From Web of "I have some doubts regarding how to implement child theme"

The first function should be there in your parent theme functions.php file.

Parent Theme Code

<?php
if ( ! function_exists( 'my_theme_enqueue_scripts' ) ) {
    function my_theme_enqueue_scripts() {
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
        function my_theme_enqueue_styles() {
            wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    }
}
?>

Child Theme Code

Now place the following code in your child theme. Setting ‘parent-style’ as a dependency will ensure that the child theme stylesheet loads after it.

if ( ! function_exists( 'my_theme_enqueue_scripts' ) ) {
    function my_theme_enqueue_scripts() {
        wp_enqueue_style( 'my_parent_style', get_template_directory_uri() . '/style.css' );
        wp_enqueue_style( 'my_child_style',
        get_stylesheet_directory_uri() . '/style.css',
            array('my_parent_style')
        );
        add_action( 'wp_enqueue_scripts','my_theme_enqueue_scripts' );
    }
}

Hope it’s clear.

2nd Doubt
It’s recommended to add the rtl.css file to your child theme even if the parent theme has no rtl.css file. rtl.css is only loaded by WordPress if is_rtl() returns true.