3v4l.org

run code in 300+ PHP versions simultaneously
<?php public function getKeywordsForURL($link_platform_product_page, $target_locale_iso, $language) { $keywords = []; if (empty($keywords)) { // Only page URL was specified, so use a UrlSeed. $requestOptionalArgs['urlSeed'] = new UrlSeed(['url' => new StringValue(['value' => $link_platform_product_page])]); } elseif (is_null($link_platform_product_page)) { // Only keywords were specified, so use a KeywordSeed. $requestOptionalArgs['keywordSeed'] = new KeywordSeed([ 'keywords' => array_map(function ($keyword) { return new StringValue(['value' => $keyword]); }, $keywords) ]); } else { // Both page URL and keywords were specified, so use a KeywordAndUrlSeed. $requestOptionalArgs['keywordAndUrlSeed'] = new KeywordAndUrlSeed([ 'url' => new StringValue(['value' => $link_platform_product_page]), 'keywords' => array_map(function ($keyword) { return new StringValue(['value' => $keyword]); }, $keywords) ]); } // Create a list of geo target constants based on the resource name of specified location // IDs. $geoTargetConstants = array_map(function ($locationId) { return new StringValue( ['value' => ResourceNames::forGeoTargetConstant($locationId)] ); }, $locationIds); // Generate keyword ideas based on the specified parameters. $response = $keywordPlanIdeaServiceClient->generateKeywordIdeas( $customerId, // Set the language resource using the provided language ID. new StringValue(['value' => ResourceNames::forLanguageConstant($language)]), // Add the resource name of each location ID to the request. $geoTargetConstants, // Set the network. To restrict to only Google Search, change the parameter below to // KeywordPlanNetwork::GOOGLE_SEARCH. KeywordPlanNetwork::GOOGLE_SEARCH_AND_PARTNERS, $requestOptionalArgs ); $keywords = ""; // Iterate over the results and print its detail. foreach ($response->getResults() as $result) { if ($result->getKeywordIdeaMetrics()->getAvgMonthlySearches()->getValue() > 10) { printf( "Keyword idea text '%s' has %d average monthly searches and competition as %d.%s", $result->getText()->getValue(), is_null($result->getKeywordIdeaMetrics()) ? 0 : $result->getKeywordIdeaMetrics()->getAvgMonthlySearches()->getValue(), is_null($result->getKeywordIdeaMetrics()) ? 0 : $result->getKeywordIdeaMetrics()->getCompetition(), PHP_EOL ); $keywords .= $result->getText()->getValue() . ","; } } return $keywords ;
Output for 7.2.0 - 7.2.29, 7.3.0 - 7.3.17, 7.4.0 - 7.4.5
Parse error: syntax error, unexpected 'public' (T_PUBLIC), expecting end of file in /in/jgthd on line 2
Process exited with code 255.

preferences:
128.61 ms | 1309 KiB | 6 Q