라이브러리
[PHP] CommonMarkNodeLink::__construct - 링크 구성
CommonMarkNodeLink::__construct
CommonMarkNodeLink는 Markdown 문법에서 링크를 표현하는 노드 클래스입니다. 이 클래스는 PHP의 Parsedown 라이브러리에 포함되어 있습니다.
# 생성자
CommonMarkNodeLink 클래스의 생성자는 다음과 같은 파라미터를 받습니다.
* `$text`: 링크의 텍스트
* `$url`: 링크의 URL
* `$title`: 링크의 제목 (선택 사항)
# 예제
#hostingforum.kr
php
require_once 'Parsedown.php';
$parsedown = new Parsedown();
$text = '[Google](https://www.google.com)';
$node = $parsedown->parse($text);
print_r($node);
위의 예제에서는 Parsedown 라이브러리를 사용하여 Markdown 문법을 파싱하고, `CommonMarkNodeLink` 노드의 생성자를 호출하여 링크 노드를 생성합니다.
# 결과
#hostingforum.kr
php
Parsedown_Node_Link Object
(
[text] => Google
[url] => https://www.google.com
[title] =>
[type] => link
)
# 생성자 사용 예제
#hostingforum.kr
php
require_once 'Parsedown.php';
$parsedown = new Parsedown();
$text = '[Google](https://www.google.com "Google Title")';
$node = $parsedown->parse($text);
print_r($node);
위의 예제에서는 링크 노드의 제목을 지정하는 방법을 보여줍니다.
# 결과
#hostingforum.kr
php
Parsedown_Node_Link Object
(
[text] => Google
[url] => https://www.google.com
[title] => Google Title
[type] => link
)
# 생성자 사용 예제 (선택 사항)
#hostingforum.kr
php
require_once 'Parsedown.php';
$parsedown = new Parsedown();
$text = '[Google](https://www.google.com)';
$node = new Parsedown_Node_Link('Google', 'https://www.google.com', 'Google Title');
print_r($node);
위의 예제에서는 `CommonMarkNodeLink` 클래스의 생성자를 직접 호출하여 링크 노드를 생성하는 방법을 보여줍니다.
# 결과
#hostingforum.kr
php
Parsedown_Node_Link Object
(
[text] => Google
[url] => https://www.google.com
[title] => Google Title
[type] => link
)
-
- 나우호스팅 @pcs8404
-
호스팅포럼 화이팅!
댓글목록
등록된 댓글이 없습니다.