PHP code example of pickles2 / px2-amp-convert

1. Go to this page and download the library: Download pickles2/px2-amp-convert library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pickles2 / px2-amp-convert example snippets



	/* 中略 */

	// funcs: Before content
	$conf->funcs->before_content = [
		// AMP変換ユーティリティオブジェクトを生成する
		'tomk79\pickles2\ampConvert\main::create_px_amp_convert_utils()',
	];

	/* 中略 */

	// processor
	$conf->funcs->processor->html = array(

		/* 中略 */

		// AMP変換
		'tomk79\pickles2\ampConvert\main::exec()',

		/* 中略 */

	);



$utils = $px->amp_convert_utils;

if(!is_object($utils)){
	// または
	$utils = new \tomk79\pickles2\ampConvert\utils( $px );
}

// パスの変換パターンを処理する
echo $utils->rewrite_path('/a/b/c/test.html', '{$dirname}/{$filename}.{$ext}'); // '/a/b/c/test.html'

// コールバックを使用する例
echo $utils->rewrite_path('/a/b/c/test.html', function($path){
	return $path.'.test';
}); // '/a/b/c/test.html.test'